﻿console.log("当前JS文件: case_build.js")
var commonFunc = {
    data: function(){
        var self = this;
    },
    serializeToObj: function(val){
        var _obj={},_val=val.split('&');
        for(var i=0,len=_val.length;i<len;i++){
            var _cache = _val[i].split('=');
            _obj[_cache[0]] = _cache[1];
        }
        return _obj;
    },
    ajax_get: function(url, param, back_success, option) {
        var self = this;
        option = option==undefined?{}: option;
        $.ajax({
            type: option.type==undefined?'GET': option.type,
            url: url,
            data: param,
            async: option.async==undefined?true: false,
            dataType: 'json',
            contentType: option.contentType==undefined?'application/json; charset=utf-8': option.contentType,
            success: function(res) {
                back_success(res);
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                if (!option.error) {
                    layer.msg('网络失败，请刷新页面后重试',{time: 1000});
                    return;
                } else {
                    option.error(XMLHttpRequest, textStatus, errorThrown);
                }
            }
        })
    },
    isEmptyObject: function(obj){
        for(var key in obj){
            return false;
        }
        return true;   
    },
    arrayMerge: function(arr1, arr2) {
        var tempArr = [];
        for(var i = 0; i < arr1.length; i ++){
           if(!commonFunc.hasOwnObject(tempArr, arr1[i])) {
                tempArr.push(arr1[i])
           }
        }
        for(var j = 0; j < arr2.length; j++) {
            if(!commonFunc.hasOwnObject(tempArr, arr2[j])) {
                tempArr.push(arr2[j])
            }
        }
        return tempArr;
    },
    isObjectValueEqual: function(obj1, obj2) {
        var aProps = Object.getOwnPropertyNames(obj1);
        var bProps = Object.getOwnPropertyNames(obj2);

        if (aProps.length != bProps.length) {
            return false;
        }

        for (var i = 0; i < aProps.length; i++) {
            var propName = aProps[i];
            if (obj1[propName] !== obj2[propName]) {
                return false;
            }
        }
        return true;
    },
    hasOwnObject: function(arr, obj){
        for(var i = 0; i < arr.length; i++) {
            if(commonFunc.isObjectValueEqual(arr[i], obj)){
                return false;
            }
        }
        return true;
    }
}
var components =
    {
    // 上传文件
    imgUpLoad: function(_this,isPdf){
        isPdf = isPdf==undefined?false: true;
        var data = new FormData();
        var _file = _this[0].files[0];
        if(isPdf){
           if(_file.type.indexOf('pdf')==-1){
                layer.msg('请上传pdf格式文件！', {time: 1000})
                return false;
            } 
        }else{
            if(_file.type.indexOf('jpeg')==-1){
                 layer.msg('请上传jpg格式图片！', {time: 1000})
                 return false;
             }
        }
        if(_file.size>1024*1024*2){
            layer.msg('文件大小不能超过2M！', {time: 1000})
            return false;
        }
        data.append('file', _file);
        isPdf?data.append('type',1): data.append('type',0);
        $.ajax({
            url: '/common/file/upload',
            type: 'POST',
            data: data,
            cache: false,
            processData: false,
            contentType: false,
            success: function (res) {
                if (res.code==9999)
                {
                    layer.msg(res.msg,{time: 1000});
                    wzERP.Common.TimeoutLogin();
                    return false;
                }
                layer.msg('上传成功',{time: 1000});
                var data = res.data;
                if(isPdf){
                    var _html = '<div class="has_uploadpdf_div">' + 
                        '<img class="upload_pdf_big" src="/static/images/pdf.png">' +
                        '<div class="upload_pdf_shadow"></div>' +
                        '<a href="'+data.filePath+'" target="_blank" class="open_new_pdf upload_pdf_small"><img src="/static/images/zoom.png"></a>' +
                        '<a href="javascript:void(0);" class="upload_pdf_small refresh_pdf"><img src="/static/images/load.png"></a>' +
                    '</div>';
                    $(_html).insertBefore(_this.prev()).hover(function() {
                        $(this).addClass('active');
                    }, function() {
                        $(this).removeClass('active');
                    }).find('.refresh_pdf').on('click',function(){
                        $(this).parent().next().click()
                    })
                }else{
                    _this.prev().html('<img src="' + data.filePath + '" style="width:100px;height:100px" />');
                }
                _this.next().val(data.filePath);
            },
            error: function (res) {
                layer.msg('网络失败，请刷新页面后重试',{time:2000});
            }
        });
    },
    //上传pdf
    uploadFilePdf:function(body_ele,ele_trigger,ele_form){
        /*Arg Guide
         @ trigger_id 触发按钮id(label)
         @ form_id 表单提交的id
        */
        $(body_ele).on('click',ele_trigger,function(){
            var $self = $(this);
            var input_name = $(this).attr('for');
            var $input_file = $('#'+input_name); //获取上传文件的input
            var maxSize = 2 * 1024 * 1024;//最大容量
            $input_file.off('change').change(function(){
                var $iVal = $input_file.val();
                if($iVal){
                    if(!$iVal.endsWith('pdf')){
                        layer.msg('请上传pdf格式', {icon: 5})
                    }else {
                        if($input_file[0].files[0].size > maxSize){
                            layer.msg('上传pdf不能超过2M', {icon: 5});
                            return false;
                        }
                        $(ele_form).ajaxSubmit({
                            type: 'POST',
                            success: function (result) {
                                if (result.code == 0) {
                                    var filePath = result.data.filePath;
                                    var fileName = result.data.fileName;
                                    $self.text('重新上传证明');
                                    $self.siblings('a').remove('.seePdf')
                                    $self.parent().prepend('<a class="ui orange button seePdf" href="'+filePath+'" style="display:inline-block" target="_blank">预览</a>');
                                    $self.siblings('input[type="hidden"]').val(filePath);
                                    $input_file.val('');
                                    layer.msg('上传成功!', {icon: 7});
                                }
                                else if (result.code==9999)
                                {
                                    layer.msg(result.msg,{time: 1000});
                                    wzERP.Common.TimeoutLogin();
                                    return false;
                                }
                            }
                        });
                    }
                }
            })
        })
    },
    //客户信息获取
    customer_data_get: function(id){
        var _url = case_build.urlLink.customer_data; //客户信息接口获取
        var _param = {id: id};
        var succ = function(res){
            if(res.code == 0){
                case_build._customerDate = res.data; //注册账号信息
            }
            else if (res.code==9999)
            {
                layer.msg(res.msg,{time: 1000});
                wzERP.Common.TimeoutLogin();
                return false;
            }
            else{
                layer.msg('客户信息获取失败，请刷新页面重试！',{time: 1000});
            }
        }
        commonFunc.ajax_get(_url,_param,succ,{async: false});
    },
    // 获取公司列表
    company_lt_get: function($el){
        var _url = ol_inf_lt.company_lt;
        var _param = {};
        var succ = function(res){
            if(res.code == 0){
                var _html = '<option value="" selected>请选择公司</option>';
                $.each(res.data,function(i,v){
                    _html += '<option value="' + v.companyCode + '">' + v.companyName + '</option>'
                })
                $el.html(_html);
            }else{
                layer.msg('公司列表列表获取失败，请刷新页面重试！',{time: 1000});
            }
        }
        commonFunc.ajax_get(_url,_param,succ);
    },
    // 获取服务分类
    svLtGet: function($el){
        var _url = ol_inf_lt.sv_lt;
        var _param = {};
        var succ = function(res){
            if(res.code == 0){
                var _html = '<option value="" selected>请选择服务</option>';
                $.each(res.data,function(i,v){
                    _html += '<option value="' + v.key + '">' + v.value + '</option>'
                })
                $el.html(_html);
            }else{
                layer.msg('服务分类列表获取失败，请刷新页面重试！',{time: 1000});
            }
        }
        commonFunc.ajax_get(_url,_param,succ);
    },
}   
var case_build = {
    // 新建立案dlg 方法 option=> id;
	pop: function(option){
		var self = this;
		//配置项初始化
		self.init(option.url);
		self.option=option==undefined?self.option: $.extend(self.option,option); 
		//子订单详情储存
		self.cd_od_dt_get(option); 
		//立案dom_top render
        self.cd_od_dt.user_nickname = option.user_nickname!=undefined?option.user_nickname: self.cd_od_dt.nickname;
		var case_cont_top_tpl = template('case_cont_top_tpl', self.cd_od_dt);
		$('#case_build_dlg .case_cont_top').html(case_cont_top_tpl);
        // 添加案件//删除案件事件绑定
        self.caseDlg_open_evBind(option);
        // 提交数据初始化
        self.case_submit_data_init();  
        // 弹出立案模态框
        $('#case_build_dlg').modal({
            closable: false,
            transition: 'fade',
            onHidden: function(){
                $('#case_build_dlg .case_cont_top').html('');
                $('#case_build_dlg .case_cont_body').html('');
            }
        }).modal('show');
	},
    //edit
    editPop: function(option){
        var self = this;
        //配置项初始化
        _url = option.orderType==0?'/order/offline/detail': '/order/online/detail';
        self.init(_url);
        self.option=option==undefined?self.option: $.extend(self.option,option); 

        //子订单详情储存 可立案信息获取
        self.cd_od_dt_get(option);
        //立案dom_top render

        // 立案详情
        self.cases_detail_get(option.id);
        //建立案件头部 渲染
        self.cases_detail.filingInfo.companyName = self.cases_detail.filingInfo.customerName; //客户名称
        self.cases_detail.filingInfo.user_nickname = self.cases_detail.filingInfo.createName; //立案人
        self.cases_detail.filingInfo.isedit = 1;//是否是编辑
        var case_cont_top_tpl = template('case_cont_top_tpl', self.cases_detail.filingInfo);
        $('#case_build_dlg .case_cont_top').html(case_cont_top_tpl);
        //案件body部分渲染
        self.case_cont_body_render();

        //-----------添加案件部分待补充---------------
        // 添加案件//删除案件事件绑定
        option.isedit = 1;
        self.caseDlg_open_evBind(option);
        //-------------------------------------------
        // 提交数据初始化
        self.case_submit_data_init();
        // 弹出立案模态框
        $('#case_build_dlg').modal({
            closable: false,
            transition: 'fade',
            onHidden: function(){
                $('#case_build_dlg .case_cont_top').html('');
                $('#case_build_dlg .case_cont_body').html('');
            }
        }).modal('show');
    },
  
    //立案body部分渲染
    case_cont_body_render: function(){
        var self = this;
        var _html = ''; 
        var _data = self.cases_detail;
        if(_data.registList.length!=0){
            $.each(self.cases_detail.registList,function(index,value){
                value = $.extend(value,{labelSort:self.labelSort++,labelSort_w: self.labelSort_w++});
            })
            var _tpl = template('trademark_regist_ed', self.cases_detail);
            _html += _tpl;
        }
        if(_data.transferList.length!=0){
            $.each(self.cases_detail.transferList,function(index,value){
                value = $.extend(value,{labelSort:self.labelSort++,labelSort_w: self.labelSort_w++});
                $.each(value.contactList,function(index,val){
                    val = $.extend(val,{labelSort:self.labelSort++,labelSort_w: self.labelSort_w++});
                })
            })
            
            var _tpl = template('trademark_transfer_ed', self.cases_detail);
            _html += _tpl;
        }if(_data.changeList.length!=0){
            $.each(self.cases_detail.changeList,function(index,value){
                value = $.extend(value,{labelSort:self.labelSort++,labelSort_w: self.labelSort_w++});
                $.each(value.registerList,function(index,val){
                    val = $.extend(val,{labelSort:self.labelSort++,labelSort_w: self.labelSort_w++});
                })
            })
            var _tpl = template('trademark_change_ed', self.cases_detail);
            _html += _tpl;
        }if(_data.extendList.length!=0){
            $.each(self.cases_detail.extendList,function(index,value){
                value = $.extend(value,{labelSort:self.labelSort++,labelSort_w: self.labelSort_w++});
            })
            var _tpl = template('trademark_extend_ed', self.cases_detail);
            _html += _tpl;
        }if(_data.licensList.length!=0){
            $.each(self.cases_detail.licensList,function(index,value){
                value = $.extend(value,{labelSort:self.labelSort++,labelSort_w: self.labelSort_w++});
            })
            var _tpl = template('trademark_licence_ed', self.cases_detail);
            _html += _tpl;
        }if(_data.certificateList.length!=0){
            $.each(self.cases_detail.certificateList,function(index,value){
                value = $.extend(value,{labelSort:self.labelSort++,labelSort_w: self.labelSort_w++});
            })
            var _tpl = template('trademark_certificate_ed', self.cases_detail);
            _html += _tpl;
        }
        $('#case_build_dlg .case_cont_body').html(_html);
        // 案件号排序
        self.case_num_sort();
        // 校正生成
        // $('.case_unit form').form(self.verifier);
        // citypicker init
        $(".region_picker_ip").citypicker();
        // 上传图片初始化
        $('.zyimg_upload_ip').change(function(){
            components.imgUpLoad($(this))
        });
        $('.zyimg_upload_ip_pdf').change(function(){
            components.imgUpLoad($(this),true)
        });
        //事件绑定
        self.form_ctrl_unit_evbind();
    },
    // 立案详情获取 
    cases_detail_get: function(id){
        var self = this;
        var _url = self.urlLink.cases_detail;
        var _param = {
            id: id,
        };
        var succ = function(res){
            if(res.code == 0){
                self.cases_detail = res.data;
            }
            else if (res.code==9999)
            {
                layer.msg(res.msg,{time: 1000});
                wzERP.Common.TimeoutLogin();
            }
            else{
                layer.msg(res.msg,{time: 1000});
            }
        }
        commonFunc.ajax_get(_url,_param,succ,{async: false,contentType: 'application/x-www-form-urlencoded'});
    },
    // component---------
    // 国际分类边输入边查询
    brand_check_func: function(searchKey,level,_this){
        var self = this;
        var _url = self.urlLink.brand_sv_classify;
        var _param = {
            searchKey: searchKey,
            level: level,
        };
        var succ = function(res){
            if(res.code == 0){
                // console.log(res);
                if(res.data.length==0){
                    layer.msg('无匹配结果！请重新输入检索内容',{time: 1000});
                }
                var data = res.data,_html='';
                $.each(data,function(index,value){
                    _html += '<div data-id="'+ value.bigtypeid +'" class="classify_cont_unit">'+ value.bigtypename +'</div>';
                });
                _this.parent().find('.classify_cont_grp').html(_html).removeClass('zy_hide').children('.classify_cont_unit').on('click',function(){
                    var _el = _this.parents('.brand_type_lev1_div');
                    _el.find('.classify_store').val($(this).data('id'));
                    _el.find('.classify_ip').val($(this).text());
                    $(this).parent().addClass('zy_hide');
                });
            }
            else if (res.code==9999)
            {
                layer.msg(res.msg,{time: 1000});
                wzERP.Common.TimeoutLogin();
            }
            else{
                layer.msg(res.msg,{time: 1000});
            }
        }
        commonFunc.ajax_get(_url,_param,succ,{contentType: 'application/x-www-form-urlencoded'});
    },
    //商标服务三级查询dlg，左侧数据渲染
    brandlv3_rmenu_render: function (data){
        console.log(data)
        var self = this;
        var _tpl = '<h5 style="font-size: 24px;">{{data[0].bigtypename}}</h5>'+
            '{{each data v i}}'+
            '<div class="sv_lv3_unit sv_lv3_unit_lt {{if v.isact==1}}active{{/if}}" id="sv_lv3_unit{{v.smalltypeid}}" '
            + ' data-bigtypeid="{{v.bigtypeid}}"  data-bigtypename="{{v.bigtypename}}" data-midtypeid="{{v.midtypeid}}" data-midtypename="{{v.midtypename}}"'
            + ' data-smalltypeid="{{v.smalltypeid}}" data-smalltypename="{{v.smalltypename}}"'
            + '<i class="check circle icon"></i>'
            + '<span class="midtypeid">{{v.midtypeid}}</span>'
            + '-'
            + '<span class="smalltypeid">{{v.smalltypeid}}</span>'
            + '-'
            + '<div class="sv_lv3_unit_name">{{v.smalltypename}}{{isact}}</div>'
            + '</div>{{/each}}';
        var _render = template.compile(_tpl);
        var _html = _render(data);
        $('#goods_sv_selc_dlg .sv_type_cont_left').html(_html);
    },
    // 商标服务三级查询 鼠标点击后触发
    brand_checkLv3_func: function(searchKey,_this){
        // _this 为添加商品/服务按钮
        var self = this;
        var brand_lv3_obj_index = $("span.sv_btn_add.sv_btn_add_btn").index(_this)
        var _url = self.urlLink.brand_svLv3_classify;
        var _param = {
            searchKey: searchKey,
            id: _this.parents('.form_unit_line').prev().find('.classify_store').val(),
        };
        var succ = function(res){
            if(res.code == 0){
                if(res.data.length==0){
                    layer.msg('无匹配结果！',{time: 1000});
                    return;
                }
                self.brand_lv3_obj[brand_lv3_obj_index] = {}; //初始化选中数据

                var _tpl='';
                //获取页面上选择数据，这是已有的数据，需要添加新的数据
                var _els = _this.parents('.sv_3lv_btn_grp').find('.sv_btn_unit');
                var _elsData = {};
                _els.each(function(index,value){
                    var bigtypeid = $(this).attr('data-bigtypeid');
                    var bigtypename = $(this).attr('data-bigtypename');
                    var midtypeid = $(this).attr('data-midtypeid');
                    var midtypename = $(this).attr('data-midtypename');
                    var smalltypeid = $(this).attr('data-smalltypeid');
                    var smalltypename = $(this).attr('data-smalltypename');
                    if(_elsData[midtypeid] == undefined) {
                        _elsData[midtypeid] = [];
                        _elsData[midtypeid].push({
                            bigtypeid: bigtypeid,
                            bigtypename: bigtypename,
                            midtypeid: midtypeid,
                            midtypename: midtypename,
                            smalltypeid: smalltypeid,
                            smalltypename: smalltypename
                        })
                    } else {
                        _elsData[midtypeid].push({
                            bigtypeid: bigtypeid,
                            bigtypename: bigtypename,
                            midtypeid: midtypeid,
                            midtypename: midtypename,
                            smalltypeid: smalltypeid,
                            smalltypename: smalltypename
                        })
                    }
                });
                console.log(self.brand_lv3_obj)
                //  将_elsData中的数据合并到self.brand_lv3_obj中
                $.each(_elsData,function(index, data){
                    
                    if(self.brand_lv3_obj[brand_lv3_obj_index].hasOwnProperty(index)) {
                        self.brand_lv3_obj[brand_lv3_obj_index][index] = commonFunc.arrayMerge(self.brand_lv3_obj[brand_lv3_obj_index][index], data)
                    } else {
                        self.brand_lv3_obj[brand_lv3_obj_index][index] = data;
                    }
                });
                console.log(self.brand_lv3_obj)
                // 筛选 添加状态
                var resData = res;
                for(var i = 0; i<resData.data.length; i++) {
                    var val = resData.data[i];
                    resData.data[i].isact = 0;
                    var _thismidbdlt = _elsData[val.midtypeid];
                    if (_thismidbdlt!=undefined){
                        for(var j = 0; j < _thismidbdlt.length; j++) {
                            if(_thismidbdlt[j].smalltypeid == val.smalltypeid && _thismidbdlt[j].smalltypename == val.smalltypename && _thismidbdlt[j].midtypeid == val.midtypeid) {
                                resData.data[i].isact=1;
                                if(self.brand_lv3_obj[brand_lv3_obj_index][val.midtypeid]==undefined){
                                    self.brand_lv3_obj[brand_lv3_obj_index][val.midtypeid]=[];
                                    self.brand_lv3_obj[brand_lv3_obj_index][val.midtypeid].push({
                                        bigtypeid: val.bigtypeid,
                                        bigtypename: val.bigtypename,
                                        midtypename: val.midtypename,
                                        smalltypeid: val.smalltypeid,
                                        smalltypename: val.smalltypename
                                    });
                                } else {
                                }
                            }
                        }
                    }
                }
                console.log(self.brand_lv3_obj)
                //左侧数据渲染
                self.brandlv3_rmenu_render(resData);
                console.log(self.brand_lv3_obj)

                if(!commonFunc.isEmptyObject(_elsData)){
                    self.update_seleclv3(_this);
                }
                   
                self.brand_check_dlg_evbind(_this);
            }
            else if (res.code==9999)
            {
                layer.msg(res.msg,{time: 1000});
                wzERP.Common.TimeoutLogin();
            }
            else{
                layer.msg(res.msg,{time: 1000});
            }

        }
        commonFunc.ajax_get(_url,_param,succ,{contentType: 'application/x-www-form-urlencoded'});
    },
    brand_check_dlg_evbind: function(_this){
        // _this 为添加商品/服务按钮
        var self = this;
        var _pel = $('#goods_sv_selc_dlg');
        var brand_lv3_obj_index = $("span.sv_btn_add.sv_btn_add_btn").index(_this)
        // 左侧菜单点击事件绑定
        _pel.find('.sv_lv3_unit_lt').off('click').on('click',function(){
            var bigtypeid = $(this).attr('data-bigtypeid');
            var bigtypename = $(this).attr('data-bigtypename');
            var midtypeid = $(this).attr('data-midtypeid');
            var midtypename = $(this).attr('data-midtypename');
            var smalltypeid = $(this).attr('data-smalltypeid');
            var smalltypename = $(this).attr('data-smalltypename');
            if(!$(this).hasClass('active')){
                // 添加
                $(this).addClass('active');
                if(self.brand_lv3_obj[brand_lv3_obj_index][midtypeid]!=undefined){
                    self.brand_lv3_obj[brand_lv3_obj_index][midtypeid].push({
                        bigtypeid: bigtypeid,
                        bigtypename: bigtypename,
                        midtypeid: midtypeid,
                        midtypename: midtypename,
                        smalltypeid: smalltypeid,
                        smalltypename: smalltypename,
                    });
                }else{
                    self.brand_lv3_obj[brand_lv3_obj_index][midtypeid] = [];
                    self.brand_lv3_obj[brand_lv3_obj_index][midtypeid].push({
                        bigtypeid: bigtypeid,
                        bigtypename: bigtypename,
                        midtypeid: midtypeid,
                        midtypename: midtypename,
                        smalltypeid: smalltypeid,
                        smalltypename: smalltypename,
                    });

                }

                var _html = '<span class="sv_btn_unit" id="sv_btn_un' + midtypeid + '_' + smalltypeid
                    + '" data-bigtypeid="' + bigtypeid + '" data-bigtypename="' + bigtypename
                    + '" data-midtypeid="' + midtypeid + '" data-midtypename="' + midtypename
                    + '" data-smalltypeid="' + smalltypeid + '" data-smalltypename="' + smalltypename
                    + '"><span>'
                    + midtypeid + '</span>-<span>' + smalltypeid +'</span>-<span class="smalltypename">' + smalltypename+'</span></span>'
                $(".sv_3lv_btn_grp").eq(brand_lv3_obj_index).append(_html);
            }else{
                // 移除
                $(this).removeClass('active');
                for (var i = 0; i < self.brand_lv3_obj[brand_lv3_obj_index][midtypeid].length; i++) {
                    if (self.brand_lv3_obj[brand_lv3_obj_index][midtypeid][i]['smalltypeid'] == smalltypeid && self.brand_lv3_obj[brand_lv3_obj_index][midtypeid][i]['smalltypename'] == smalltypename) {
                        self.brand_lv3_obj[brand_lv3_obj_index][midtypeid].splice(i, 1)
                    }
                }
                if (self.brand_lv3_obj[brand_lv3_obj_index][midtypeid].length == 0) {
                    delete self.brand_lv3_obj[brand_lv3_obj_index][midtypeid];
                }
                _this.parent().find('#sv_btn_un' + midtypeid + '_' + smalltypeid).remove();
            }
            self.update_seleclv3(_this);

            _this.parent().find('.sv_btn_unit').on('click',function(){
                $(this).remove();
                var midtypeid = $(this).attr('data-midtypeid');
                var smalltypeid = $(this).attr('data-smalltypeid');
                var smalltypename = $(this).find('.smalltypename').html().trim();
                $.each(self.brand_lv3_obj[brand_lv3_obj_index], function(index, value){
                    for(var i =0; i< value.length; i++){
                        if(midtypeid == value[i].midtypeid && smalltypeid == value[i].smalltypeid && smalltypename == value[i].smalltypename) {
                            value.splice(i,1)
                        }
                    }
                    if(value.length == 0){
                        delete self.brand_lv3_obj[brand_lv3_obj_index][index]
                    }
                })
                console.log(self.brand_lv3_obj)
            })

        })
        // 提交绑定
        _pel.find('.sv_lv3_submit').off('click').on('click',function(){
            var _html = '',_bdlv3={};
            // 整理搜索数据
            $.each(self.brand_lv3_obj[brand_lv3_obj_index],function(key,value){
                $.each(self.brand_lv3_obj[brand_lv3_obj_index][key],function(ckey,value){
                    _bdlv3[ckey] = {
                        name: value.name,
                        mid: key,
                    };
                })
            });
            // 获取页面元素的 生成数据
            // 待修改
            var _els = _this.parent().find('.sv_btn_unit'),_cache_bdlv3={};
            _els.each(function(index){
                _cache_bdlv3[$(this).data('id')] = {
                    name: $(this).text(),
                    mid: $(this).data('mid'),
                };
            });
            //合并 本次和已选
            $.extend(_bdlv3,_cache_bdlv3);
            //生成页面元素 
            _this.parent().find('.sv_btn_unit').remove();

            $.each(self.brand_lv3_obj[brand_lv3_obj_index], function(index, value){
                
                for(var i = 0; i< value.length; i++) {
                    _html += '<span class="sv_btn_unit" id="sv_btn_un' + index + '_' + value[i].smalltypeid
                        + '" data-bigtypeid="' + value[i].bigtypeid + '" data-bigtypename="' + value[i].bigtypename
                        + '" data-midtypeid="' + value[i].midtypeid + '" data-midtypename="' + value[i].midtypename
                        + '" data-smalltypeid="' + value[i].smalltypeid + '" data-smalltypename="' + value[i].smalltypename
                        + '"><span>'
                        + value[i].midtypeid + '</span>-<span>' + value[i].smalltypeid +'</span>-<span class="smalltypename">' + value[i].smalltypename+'</span></span>'
                }
            })

            $(_html).insertAfter(_this);
            // 外层商品服务按钮点击事件
            _this.parent().find('.sv_btn_unit').on('click',function(){
                $(this).remove();
                var midtypeid = $(this).attr('data-midtypeid');
                var smalltypeid = $(this).attr('data-smalltypeid');
                var smalltypename = $(this).find('.smalltypename').html().trim();
                $.each(self.brand_lv3_obj[brand_lv3_obj_index], function(index, value){
                    for(var i =0; i< value.length; i++){
                       if(midtypeid == value[i].midtypeid && smalltypeid == value[i].smalltypeid && smalltypename == value[i].smalltypename) {
                           value.splice(i,1)
                       }
                    }
                    if(value.length == 0){
                        delete self.brand_lv3_obj[brand_lv3_obj_index][index]
                    }
                })
                console.log(self.brand_lv3_obj)
            })
            //关闭弹窗
            $('#goods_sv_selc_dlg').modal('hide');
        })
    },
    //更新服务选中状态 根据 self.brand_lv3_obj, 左侧点击更新右侧显示
    update_seleclv3: function(_this){
        // _this 为添加商品/服务按钮
        var self = this;
        var brand_lv3_obj_index = $("span.sv_btn_add.sv_btn_add_btn").index(_this)
        var _html = '';
        var data = self.brand_lv3_obj[brand_lv3_obj_index];
        _html = template('goods_sv_selc_right',data);
        // 右侧点击事件绑定
        $('#goods_sv_selc_dlg .sv_type_cont_right').html(_html).find('.sv_lv3_unit').on('click',function(){
            var bigtypeid = $(this).attr('data-bigtypeid');
            var bigtypename = $(this).attr('data-bigtypename');
            var midtypeid = $(this).attr('data-midtypeid');
            var midtypename = $(this).attr('data-midtypename');
            var smalltypeid = $(this).attr('data-smalltypeid');
            var smalltypename = $(this).attr('data-smalltypename');
            for (var i = 0; i < self.brand_lv3_obj[brand_lv3_obj_index][midtypeid].length; i ++) {
                if(self.brand_lv3_obj[brand_lv3_obj_index][midtypeid][i]['smalltypeid'] == smalltypeid && self.brand_lv3_obj[brand_lv3_obj_index][midtypeid][i]['midtypeid'] == midtypeid && self.brand_lv3_obj[brand_lv3_obj_index][midtypeid][i]['smalltypename'] == smalltypename) {
                    self.brand_lv3_obj[brand_lv3_obj_index][midtypeid].splice(i,1)
                }
            }
            $('#goods_sv_selc_dlg').find('#sv_lv3_unit'+ smalltypeid).removeClass('active');//左侧菜单更新状态
            if(self.brand_lv3_obj[brand_lv3_obj_index][midtypeid].length > 0) {
                $(this).remove();
            }else{
                delete self.brand_lv3_obj[brand_lv3_obj_index][midtypeid];
                $(this).parents('.sv_lv23_selc_grp').remove();
            }
            _this.parents(".sv_btn_grp ").find('#sv_btn_un'+ midtypeid+'_'+smalltypeid).remove();
        });
    },
    // 商标三级分类dlg 事件绑定
    brand_lv3Dlg_evbind: function(_this){
        // _this 为添加商品/服务按钮
        var brand_lv3_obj_index = $("span.sv_btn_add.sv_btn_add_btn").index(_this)
        debugger
        var self = this;
        $('#goods_sv_selc_dlg .brand_lv3_classify').off('click').on('click',function(){
            self.brand_lv3_obj[brand_lv3_obj_index] = {};
            var searchKey = $(this).prev().val();
            self.brand_checkLv3_func(searchKey,_this);
        }).trigger('click');
    },
    //city-picker填值  提交用 self.city_picker_form_data_set()
    city_picker_form_data_set: function(){
        $('.region_picker_ip').each(function(index,el){
            var _areaEl = $(this).next().find('.select-item');
            var _areaIp = $(this).parent().find('.region_unit_ip');
            _areaIp.each(function(index, el) {
                $(this).val('');//清除原值
                if(index+1>_areaEl.length) return false;
                $(this).val(_areaEl.eq(index).data('code'));
            });
        })
    },
    // component----------

    // 可立案sku dlg 部分----------
    //子订单详情查询--可立案sku信息获取 
    cd_od_dt_get: function(option){
        var self = this;
        var _url = self.urlLink.cd_od_dt;
        var _param = {
            orderCode: option.orderCode!=undefined?option.orderCode: '',
            // id: option.id!=undefined?option.id: '',
            filter: 1,
        };
        var succ = function(res){
            if(res.code == 0){
                self.cd_od_dt = res.data;
            }
            else if (res.code==9999)
            {
                layer.msg(res.msg,{time: 1000});
                wzERP.Common.TimeoutLogin();
            }
            else{
                layer.msg(res.msg,{time: 1000});
            }
        }
        commonFunc.ajax_get(_url,_param,succ,{async: false});
    },
    //立案dlg 固定元素 事件绑定
    caseDlg_open_evBind: function (option) {
        var self = this;
        //添加案件
        $('.case_cont_top .casedlg_addcase_btn').off('click').on('click',function () {
            //ske选择数据填充
            var case_cont_top_tpl = template('may_case_svlt_tpl', self.cd_od_dt);
            $('.may_caselt_cont_block').html(case_cont_top_tpl); 
            //已建立案件数据提取,并渲染
            if($('#case_build_dlg .case_unit').length != 0) self.get_built_case_num();
            // 选择可立案sv 事件绑定
            self.busiSelcEvBind();
            $('.case_busi_selc_dlg').modal({
                closable: false,
                transition: 'fade',
                allowMultiple: true
            }).modal('show');
        });
        //删除案件
        $('.case_cont_top .casedlg_deletcase_btn').off('click').on('click',function () {
            var length = $('#case_build_dlg .case_ckbox_unit:checked').length;
            if(length == 0)
            {
                layer.msg('请勾选案件',{time:1000});
                return false;
            }
            //删除判定
            layer.alert('确定删除案件吗？', {
                    title: '提示信息',
                    btn: ['取消', '确认'],
                    btn1:function(index){
                        layer.close(index)
                    },
                    btn2:function(){
                        //删除动作
                        self.case_delete_submit();
                    }
                }
            );
            // $('.case_ckbox_unit:checked').parents('.case_unit').remove();
            // self.case_num_sort();
        });
        // 立案提交
        self.multCaseClick = false;
        $('.case_submit').off('click').on('click',function(){
            if(self.multCaseClick){
                console.log('d');
                return;
            }else{
                console.log('f');
                self.multCaseClick = true;
            }
            $(this).attr('disabled','disabled');
            self.case_build_submit(option._this,option.isedit,$(this));
        })
    },
    // 立案数据 初始化
    case_submit_data_init: function(isedit){
        var self = this;
        console.log("self.option.orderType:"+self.option.orderType);
        self.submit_data = {
            orderType: self.option.orderType,
            orderCode: self.option.orderCode,
            custId: self.cd_od_dt.custId,
            acceptName: self.cd_od_dt.acceptName,
            registList: [],//商标注册
            transferList: [],//商标转让
            changeList: [],//商标变更
            extendList: [],//商标续展
            licensList: [],//商标许可
            certificateList: [],//商标补证
        };    
        if(isedit==1){
            self.submit_data.id = self.cases_detail.filingInfo.id;
            self.submit_data.orderType = self.cases_detail.filingInfo.orderType;
            self.submit_data.orderCode = self.cases_detail.filingInfo.orderCode;
            self.submit_data.custId = self.cases_detail.filingInfo.custId;
            self.submit_data.signOrder = self.cases_detail.filingInfo.signOrder;
            self.submit_data.updateUser = self.cases_detail.filingInfo.updateUser;
            self.submit_data.companyCode = self.cases_detail.filingInfo.companyCode;
        }
    },
    //已建立案件数据提取,并渲染
    get_built_case_num: function(){
        var self = this;
        self.cacheFormData = {};
        $('#case_build_dlg .case_unit').each(function(index,val){
            var _type = $(this).data('type'),_cid=$(this).data('cid');
            if(_cid=='') self.cacheFormData[_type]==undefined?self.cacheFormData[_type]=1: self.cacheFormData[_type]+=1;
        });
        var _actEl = $('#case_busi_selc_dlg');
        $.each(self.cacheFormData,function(key,val){
            _actEl.find('#skunum_'+key).data('min',val).val(val);
        })
    },
    //案件删除 （已立案部分）
    case_delete_submit: function(){
        var self = this;
        var _url = self.urlLink.case_delete;
        var _param = {
            orderCode: !commonFunc.isEmptyObject(self.cases_detail)?self.cases_detail.filingInfo.orderCode: null,
            caseIds: [],
        }
        $('#case_build_dlg .case_ckbox_unit:checked').each(function(index,value){
            var _cid = $(this).parents('.case_unit').data('cid');
            if(_cid != '') _param.caseIds.push(_cid);
        });
        _param = JSON.stringify(_param);
        var succ = function(res){
            if(res.code == 0){
                layer.msg(res.msg,{time: 1000});
                $('#case_build_dlg .case_ckbox_unit:checked').parents('.case_unit').remove();
                self.case_num_sort();//排序
                var length = $('#case_build_dlg .case_ckbox_unit').length;
                if(length == 0)
                {
                    $('.case_cont_top .casedlg_deletcase_btn').attr('disabled','disabled');
                }
            }
            else if (res.code==9999)
            {
                layer.msg(res.msg,{time: 1000});
                wzERP.Common.TimeoutLogin();
            }
            else{
                layer.msg(res.msg,{time: 1000});
            }
        }
        commonFunc.ajax_get(_url,_param,succ,{type: 'POST'});
    },
    // 可立案sku dlg 部分结束-------

    // sku选择=>生成立案表单 部分--------
    //可立案sku选择dlg---事件绑定
    busiSelcEvBind: function () {
        var self = this;
        self.multSvClick = false;
        // 提交表单
        $('.zy_case_build_submit').off('click').on('click',function(){
            if(self.multSvClick){
                return;
            }else{
                self.multSvClick = true;
            }
            $(this).prop('disabled', true);
            // console.log(new Date().getTime());
            var _this = $(this);
            //数目验证部分
            if($('.case_busi_unit_selc:checked').length==0) {
                layer.msg('未选择立案服务！',{time: 2000});
                _this.prop('disabled',false);
                self.multSvClick = false;
                return;
            }
            var _hasNum = false;
            $('.case_busi_unit_selc:checked').each(function(index, el) {
                var _num = $(this).parents('tr').find('.may_build_case_num').val(); //输入数目
                if(_num == ""){
                    _hasNum = true;
                    layer.msg('立案数不能为空！',{time: 2000});
                    return false;
                }
                if(_num==0){
                    _hasNum = true;
                    layer.msg('立案数不能为0！',{time: 2000});
                    return false;
                }
            });
            if(_hasNum) {
                _this.prop('disabled',false);
                self.multSvClick = false;
                return;
            };
            //立案表单准备部分
            var _cacheFormName = [];
            $('#case_busi_selc_dlg .case_busi_unit_selc:checked').each(function(index, el) {
                var ipEl = $(this).parents('tr').find('.may_build_case_num');
                _cacheFormName.push({
                    name: $(this).val(),
                    num: ipEl.val()-ipEl.data('min'),
                    serviceClassificationId: $(this).data('serviceclassificationid'),
                    serviceCode: $(this).data('servicecode'),
                    businessCode: $(this).data('businesscode'),
                    businessId: $(this).data('businessid'),
                    did: $(this).data('did'),
                    // caseId: $(this).data('caseId'),
                    // caseCode: $(this).data('caseCode'),
                }); 
            });
            $('.case_cont_top .casedlg_deletcase_btn').removeAttr('disabled');
            // 生成并渲染表单
            self.caseGrp_create(_cacheFormName);
            $('.case_busi_selc_dlg').modal('hide');
            _this.prop('disabled',false);
        });
        // 全选动作
        $('.case_busi_all_selc').on('click',function(){
            if($(this).is(':checked')) {
                $('.case_busi_unit_selc').prop('checked',true);
            }else{
                $('.case_busi_unit_selc').prop('checked',false);
            }
        });
        $('.case_busi_unit_selc').on('click',function(){
            if($('.case_busi_unit_selc:checked').length==$('.case_busi_unit_selc').length){
                $('.case_busi_all_selc').prop('checked',true);
            }else{
                $('.case_busi_all_selc').prop('checked',false);
            }
        });
        // 数字校正
        $('.may_build_case_num').on('keyup', function(e) {
            var _val = $(this).val().replace(/[^0-9_]/g, '');
            if(_val>$(this).data('max')-0) {
                _val = $(this).data('max');
                layer.msg('立案数不能比未立案数目大！',{time: 2000});
            }
            if(_val<$(this).data('min')-0&&$(this).data('min')-0>0){
                // _val = $(this).data('min');
                layer.msg('输入立案数目小于上一次操作时选择的数目，如果需要删除，请使用案件删除！',{time: 3000});
            }
            $(this).val(_val);
        });

        // 复制功能
        $('.case_cont_body').on('click', '.copy', function(event){
           var target = event.target;
           var case_type = $(target).parents(".case_unit").attr("data-type");
           var first_case = $('.case_cont_body').find('.case_unit[data-type=' + case_type + ']')[0];
           var current_case = $(target).parents(".case_unit");
           $(current_case).find("input").each(function(){
                if($(this).attr("type") == "text"){
                    var name = $(this).attr("name");
                    if(name!=""){
                        var value = $(first_case).find("input[name=" + name + "]").val();
                        $(this).val(value);
                    }
                } else if($(this).attr("type") == "radio"){
                    var name = $(this).attr("name");
                    if(name!="") {
                        var value = $(first_case).find("input[name=" + name + "]:checked").val();
                        if($(this).val() == value){
                            $(this).attr("checked", true);
                        }
                    }
                }
           })
            // 拷贝上传图片
            $(current_case).find("label.img_area").each(function(index){
                var first_copy = $(first_case).find("label.img_area").eq(index).children().clone();
                $(this).html(first_copy);
            })
            // 拷贝国际分类
            $(current_case).find(".classify_ip").each(function(index){
                var classify_ip = $(first_case).find("input.classify_ip").eq(index).val()
                $(this).val(classify_ip);
            })
            $(current_case).find(".classify_store").each(function(index){
                var classify_store = $(first_case).find("input.classify_store").eq(index).val()
                $(this).val(classify_store);
            })

            // 拷贝营业执照

            // 拷贝地址

            // 拷贝商品服务
            $(current_case).find(".sv_3lv_btn_grp ").empty().append($(first_case).find(".sv_3lv_btn_grp").children().clone());
            $(current_case).find('.sv_btn_unit').on('click',function(){
                $(this).remove();
                var brand_lv3_obj_index = $(".case_unit").index(current_case)
                debugger
                var midtypeid = $(this).attr('data-midtypeid');
                var smalltypeid = $(this).attr('data-smalltypeid');
                var smalltypename = $(this).find('.smalltypename').html().trim();
                $.each(self.brand_lv3_obj[brand_lv3_obj_index], function(index, value){
                    for(var i =0; i< value.length; i++){
                        if(midtypeid == value[i].midtypeid && smalltypeid == value[i].smalltypeid && smalltypename == value[i].smalltypename) {
                            value.splice(i,1)
                        }
                    }
                    if(value.length == 0){
                        delete self.brand_lv3_obj[brand_lv3_obj_index][index]
                    }
                })
            })
            // 拷贝注册人国籍
            var nationality = $(first_case).find("select[name=nationality]").val();
            $(current_case).find("select[name=nationality] option").each(function(){
                if($(this).val() == nationality){
                    $(this).attr("selected", true);
                }
            });

            var changeType = $(first_case).find("select[name=changeType]").val();
            $(current_case).find("select[name=changeType] option").each(function(){
                if($(this).val() == changeType){
                    $(this).attr("selected", true);
                }
            });
            // 拷贝商标注册证
            $(current_case).find(".upload_dp_blc").each(function(index){
                var toClone = $(first_case).find(".upload_dp_blc").eq(index).children(".has_uploadpdf_div");
                if(toClone.length > 0) {
                    $(this).find(".has_uploadpdf_div").remove().end().prepend(toClone.clone());
                }
                $(this).find("label").html("点击上传");
                $('#case_build_dlg .has_uploadpdf_div').hover(function() {
                    $(this).addClass('active');
                }, function() {
                    $(this).removeClass('active');
                }).find('.refresh_pdf').on('click',function(){
                    $(this).parent().next().click()
                });
            })

            // 拷贝补证原因
            var causeDescript = $(first_case).find("textarea[name=causeDescript]").val();
            $(current_case).find("textarea[name=causeDescript]").val(causeDescript);

            // 拷贝动态添加的子表单
            $(current_case).find("form.trademark_transfer_form_child").remove();
            $(first_case).find("form.trademark_transfer_form_child").clone().appendTo(current_case);

            $(current_case).find("form.trademark_change_form_child").remove();
            $(first_case).find("form.trademark_change_form_child").clone().appendTo(current_case);

            $('#case_build_dlg .has_uploadpdf_div').hover(function() {
                $(this).addClass('active');
            }, function() {
                $(this).removeClass('active');
            }).find('.refresh_pdf').on('click',function(){
                $(this).parent().next().click()
            });

            $(".region_picker_ip").citypicker();
            $(current_case).find(".trademark_transfer_form_child").each(function(){
               $(this).find("span.city-picker-span").each(function(index){
                    if(index == 1){
                        $(this).remove();
                    }
               })
                $(this).find("span.city-picker-dropdown").each(function(index){
                    if(index== 1){
                        $(this).remove();
                    }
                })
            });
            $(current_case).find(".trademark_change_form_child").each(function(){
                $(this).find("span.city-picker-span").each(function(index){
                    if(index == 1 || index  == 3){
                        $(this).remove();
                    }
                })
                $(this).find("span.city-picker-dropdown").each(function(index){
                    if(index == 1 || index  == 3){
                        $(this).remove();
                    }
                })
            });

        })
    },
    // 立案表单生成
    caseGrp_create: function(caseGrpName){
        var self = this;
        // var _formHtml = '';
        $.each(caseGrpName,function(index,el){
            var _html='';
            for(var i=0;i<el.num;i++){
                var _el = $.extend(el,{labelSort:self.labelSort++,labelSort_w: self.labelSort_w++});
                //客户信息获取
                components.customer_data_get(self.cd_od_dt.custId);
                var _customerDate = self._customerDate;
                if(el.name=='trademark_regist'){
                    var _cacheData = {
                        proposerType: _customerDate.customerType,
                        custName: _customerDate.customerName,
                        businessLicence: _customerDate.businessLicense,
                        businessLicenceUrl: _customerDate.businessLicenseUrl,
                        provinceCode: _customerDate.provinceCode,
                        cityCode: _customerDate.cityCode,
                        county: _customerDate.countyCode,
                        provinceName: _customerDate.provinceName,
                        cityName: _customerDate.cityName,
                        countyName: _customerDate.countyName,
                        applyAddress: _customerDate.detailAddr,
                    }
                    _el = $.extend(el, _cacheData);
                }
                var _html_unit = template(el.name, _el);
                _html += _html_unit;
                console.log('2');
            }
            $('.'+el.name+'_form').length!=0? $(_html).insertAfter($('.'+el.name+'_form:last').parent()): $('.case_cont_body').append(_html);

            // _formHtml += _html
        })
        // $('.case_cont_body').html(_formHtml);
        // 案件号排序
        self.case_num_sort();
        // 校正生成
        // $('.case_unit form').form(self.verifier);
        // citypicker init  
        $(".region_picker_ip").citypicker();
        // 上传图片初始化
        $('.zyimg_upload_ip').change(function(){
            components.imgUpLoad($(this))
        });
        $('.zyimg_upload_ip_pdf').change(function(){
            components.imgUpLoad($(this),true)
        });
        //事件绑定
        self.form_ctrl_unit_evbind();
        // 隐藏同类型第一个案件的复制按钮
        $(".trademark_regist_form .copy:first").hide();
        $(".trademark_transfer_form .copy:first").hide();
        $(".trademark_extend_form .copy:first").hide();
        $(".trademark_certificate_form .copy:first").hide();
        $(".trademark_change_form .copy:first").hide();
    },   
    // 生成的案件排序（数字转中文）
    case_num_sort: function(){
        var self = this;
        $('.case_unit .case_sort_name').each(function(index,el){
            _cnNum = NumToCN.run(index+1-0);
            $(this).text('案件'+_cnNum);
        })
    },
    // form DOM元素 事件绑定
    form_ctrl_unit_evbind: function(){
        var self = this;
        //上传pdf控价事件
        $('#case_build_dlg .has_uploadpdf_div').hover(function() {
            $(this).addClass('active');
        }, function() {
            $(this).removeClass('active');
        }).find('.refresh_pdf').on('click',function(){
            $(this).parent().next().click()
        });
        //选择案件 释放窗口删除按钮
        // $('#case_build_dlg .case_ckbox_unit').off('click').on('click',function(){
        //     var _target = $('#case_build_dlg .casedlg_deletcase_btn');
        //     $('#case_build_dlg .case_ckbox_unit:checked').length>0? _target.removeAttr('disabled'): _target.attr('disabled', 'disabled');
        // });       
        // 切换商标变更表单
        $('.case_unit').off('change').on('change','.change_brand_type',function(){
            $(this).parents('.case_unit').find('.trademark_change_form_child').remove();
            var _sort = $(this).find('option:selected').index();
            var _target = "trademark_change_cform" + (_sort+1);
            var _html = template(_target,{labelSort:self.labelSort++,labelSort_w: self.labelSort_w++});
            $(_html).insertAfter($(this).parents('.case_unit').find('.trademark_change_form'));
            // init
            $(this).parents('form').next().find(".region_picker_ip").citypicker();
            $(this).parents('form').next().find(".zyimg_upload_ip").change(function(){
                components.imgUpLoad($(this))
            });
            $(this).parents('form').next().find(".zyimg_upload_ip_pdf").change(function(){
                components.imgUpLoad($(this),true)
            });
        });
        // 国际分类检索
        $(".case_unit").off('keyup').on('keyup','.classify_ip',function(){
            var _searchKey = $(this).val();
            if(_searchKey!="") {
                self.brand_check_func(_searchKey,1,$(this));
            }else{
                $(this).next().addClass('zy_hide');
                $(this).prev().val('');
            }
        });
        $(".case_unit").off('click');
        // 添加子表
        $("#case_build_dlg").on('click','.add_cd_form_btn',function(){
            debugger
            _target = $(this).data('target');
            var _html = template(_target,{labelSort:self.labelSort++,labelSort_w: self.labelSort_w++});
            $(_html).insertAfter($(this).parents('form'));
            var _cacheEl = $(this).parents('form').next();
            _cacheEl.find(".region_picker_ip").citypicker();
            _cacheEl.find(".zyimg_upload_ip").change(function(){
                components.imgUpLoad($(this))
            });
            _cacheEl.find(".zyimg_upload_ip_pdf").change(function(){
                components.imgUpLoad($(this),true)
            });
            // _cacheEl.form(self.verifier);
            var _cd_formEL = _cacheEl.find('.cd_form_tt');

            _cd_formEL.text(_cd_formEL.data('name')+NumToCN.run(_cacheEl.index()-1));

            $(this).parent().remove();
        });
        //国际商标三级分类检索
        $('.case_unit').off('click').on('click','.sv_btn_add_btn',function(){
            var _Pid = $(this).parents('.form_unit_line').prev().find('.classify_store').val();
            if(_Pid == ''){
                layer.msg('请选择国际分类',{time: 1000});
                return;
            }
            $('#goods_sv_selc_dlg').modal({
                closable: false,
                transition: 'fade',
                allowMultiple: true,
                onHidden: function(){
                    $('#goods_sv_selc_dlg .bdlv3_srh_ip').val('');
                    $('#goods_sv_selc_dlg .sv_type_cont_left').html('');
                    $('#goods_sv_selc_dlg .sv_type_cont_right').html('');
                },
            }).modal('show');
            self.brand_lv3_obj = {};
            var _this = $(this)
            _this.siblings('.sv_btn_unit').each(function(index, value){
                var bigtypeid = $(this).attr('data-bigtypeid');
                var bigtypename = $(this).attr('data-bigtypename');
                var midtypeid = $(this).attr('data-midtypeid');
                var midtypename = $(this).attr('data-midtypename');
                var smalltypeid = $(this).attr('data-smalltypeid');
                var smalltypename = $(this).attr('data-smalltypename');
                if(self.brand_lv3_obj[midtypeid]!=undefined) {
                    self.brand_lv3_obj[midtypeid].push({
                        bigtypeid: bigtypeid,
                        bigtypename: bigtypename,
                        midtypeid: midtypeid,
                        midtypename: midtypename,
                        smalltypeid: smalltypeid,
                        smalltypename: smalltypename,
                    });
                } else {
                    self.brand_lv3_obj[midtypeid] = [];
                    self.brand_lv3_obj[midtypeid].push({
                        bigtypeid: bigtypeid,
                        bigtypename: bigtypename,
                        midtypeid: midtypeid,
                        midtypename: midtypename,
                        smalltypeid: smalltypeid,
                        smalltypename: smalltypename,
                    });
                }
            });
            self.brand_lv3Dlg_evbind(_this);
            $('#goods_sv_selc_dlg .brand_lv3_classify').click();
        });
        $('.sv_btn_unit').off('click').on('click',function(){
            $(this).remove();
        })
    },
    // sku选择=>生成立案表单 结束-------

    // 立案提交部分--------
    // 立案 formdata 整理
    caseSubmit_formdata: function(isedit){
        var self = this;
        // 数据初始化
        self.case_submit_data_init(isedit);
        // 公共参数填充
        // city_picker 部分
        self.city_picker_form_data_set();
        // 国内商标注册
        $('.trademark_regist_form').each(function(index, el) {
            var _obj = commonFunc.serializeToObj(decodeURIComponent($(this).serialize(),true));
            var _array = [];
            $(this).find('.sv_btn_unit').each(function(){
                var bigtypeid = $(this).attr('data-bigtypeid');
                var bigtypename = $(this).attr('data-bigtypename');
                var midtypeid = $(this).attr('data-midtypeid');
                var midtypename = $(this).attr('data-midtypename');
                var smalltypeid = $(this).attr('data-smalltypeid');
                var smalltypename = $(this).attr('data-smalltypename');
                _array.push({
                    bigtypeid: bigtypeid,
                    bigtypename: bigtypename,
                    midtypeid: midtypeid,
                    midtypename: midtypename,
                    smalltypeid: smalltypeid,
                    smalltypename: smalltypename,
                })
            });
            _obj.internationDetailList = _array;
            self.submit_data.registList.push(_obj);
        });  
        // 商标转让
        $('.trademark_transfer_form').each(function(index, el) {
            var _obj = commonFunc.serializeToObj(decodeURIComponent($(this).serialize(),true));
            _obj.contactList = [];
            $(this).parent().find('.trademark_transfer_form_child').each(function(index, el){
                var _objChild =  commonFunc.serializeToObj(decodeURIComponent($(this).serialize(),true));
                _obj.contactList.push(_objChild);
            })
            self.submit_data.transferList.push(_obj)
        });
        // 商标变更
        $('.trademark_change_form').each(function(index, el) {
            _thisp = $(this);
            var _obj = commonFunc.serializeToObj(decodeURIComponent($(this).serialize(),true));
            _obj.registerList = [];
            $(this).parent().find('.trademark_change_form_child').each(function(index, el){
                var _objChild =  commonFunc.serializeToObj(decodeURIComponent($(this).serialize(),true));
                var _name = _thisp.find('.change_brand_type option:selected').data('field');
                _name=='registerList'?_obj[_name].push(_objChild): _obj[_name]=_objChild;
            });
            self.submit_data.changeList.push(_obj);
        });
        // 商标续展、宽展
        $('.trademark_extend_form').each(function(index, el) {
            var _obj = commonFunc.serializeToObj(decodeURIComponent($(this).serialize(),true));
            self.submit_data.extendList.push(_obj)
        });
        // 商标许可
        $('.trademark_licence_from').each(function(index, el) {
            var _obj = commonFunc.serializeToObj(decodeURIComponent($(this).serialize(),true));
            self.submit_data.licensList.push(_obj)
        });
        // 商标补证
        $('.trademark_certificate_form').each(function(index, el) {
            var _obj = commonFunc.serializeToObj(decodeURIComponent($(this).serialize(),true));
            self.submit_data.certificateList.push(_obj)
        });
    },  
    // 立案表单提交   
    case_build_submit: function(_this,isedit,_btnAc){
        var self = this;
        $('.case_unit form').form('submit');
        // formdata 整理
        self.caseSubmit_formdata(isedit);
        // 表单验证标红
        console.log(self.submit_data)

        if(self.submit_data.registList.length > 0) {
            var canSubmit = true;
            var registListError = [];
            var currentErrorMsg = '';
            for (var i = 0; i <  self.submit_data.registList.length; i++) {
                var register = self.submit_data.registList[i];
                var registerError = this.validateTrademarkRegist(register);
                registListError.push({
                    'index': i,
                    'error': registerError,
                });
                currentErrorMsg = registerError.currentErrorMsg;
            }
            if(currentErrorMsg.length > 0) {
                layer.msg(currentErrorMsg[0], {icon: 5})
            }
            canSubmit = self.displayFormErrors('.trademark_regist_form', registListError);
            if(!canSubmit) {
                _btnAc.removeAttr('disabled');
                self.multCaseClick = false;
                return false;
            }
        }
        if(self.submit_data.licensList.length > 0) {
            var canSubmit = true;
            var licensListError = [];
            var currentErrorMsg = '';
            for (var i = 0; i <  self.submit_data.licensList.length; i++) {
                var licens = self.submit_data.licensList[i];
                console.log(licens)
                var licensError = this.validateTrademarkLicence(licens);
                console.log(licensError)
                licensListError.push({
                    'index': i,
                    'error': licensError,
                });
                currentErrorMsg = licensError.currentErrorMsg;
            }
            if(currentErrorMsg.length > 0) {
                layer.msg(currentErrorMsg[0], {icon: 5})
            }
            console.log(licensListError)
            canSubmit = self.displayFormErrors('.trademark_licence_from', licensListError);
            if(!canSubmit) {
                _btnAc.removeAttr('disabled');
                self.multCaseClick = false;
                return false;
            }
        }

        if(self.submit_data.extendList.length > 0) {
            var canSubmit = true;
            var extendListError = [];
            var currentErrorMsg = '';
            for (var i = 0; i <  self.submit_data.extendList.length; i++) {
                var extend = self.submit_data.extendList[i];
                var extendError = this.validateTrademarkExtend(extend);
                extendListError.push({
                    'index': i,
                    'error': extendError,
                });
                currentErrorMsg = extendError.currentErrorMsg;
            }
            if(currentErrorMsg.length > 0) {
                layer.msg(currentErrorMsg[0], {icon: 5})
            }
            console.log(extendListError)
            canSubmit = self.displayFormErrors('.trademark_extend_form', extendListError);
            if(!canSubmit) {
                _btnAc.removeAttr('disabled');
                self.multCaseClick = false;
                return false;
            }
        }

        if(self.submit_data.transferList.length > 0) {
            var canSubmit = true;
            var transferListError = [];
            var currentErrorMsg = '';
            for (var i = 0; i <  self.submit_data.transferList.length; i++) {
                var transfer = self.submit_data.transferList[i];
                var transferError = this.validateTrademarkTransfer(transfer);
                transferListError.push({
                    'index': i,
                    'error': transferError,
                });
                currentErrorMsg = transferError.currentErrorMsg;
            }
            if(currentErrorMsg.length > 0) {
                layer.msg(currentErrorMsg[0], {icon: 5})
            }
            console.log(transferListError)
            canSubmit = self.displayFormErrors('.trademark_transfer_form', transferListError);
            if(!canSubmit) {
                _btnAc.removeAttr('disabled');
                self.multCaseClick = false;
                return false;
            }
        }

        if(self.submit_data.changeList.length > 0) {
            var canSubmit = true;
            var changeListError = [];
            var currentErrorMsg = '';
            for (var i = 0; i <  self.submit_data.changeList.length; i++) {
                var change = self.submit_data.changeList[i];
                var changeError = this.validateTrademarkChange(change);
                changeListError.push({
                    'index': i,
                    'error': changeError,
                });
                currentErrorMsg = changeError.currentErrorMsg;
            }
            if(currentErrorMsg.length > 0) {
                layer.msg(currentErrorMsg[0], {icon: 5})
            }
            console.log(changeListError)
            canSubmit = self.displayFormErrors('.trademark_change_form', changeListError);
            if(!canSubmit) {
                _btnAc.removeAttr('disabled');
                self.multCaseClick = false;
                return false;
            }
        }
        if (self.submit_data.certificateList.length > 0) {
            var canSubmit = true;
            var certificateListError = [];
            var currentErrorMsg = '';
            for (var i = 0; i <  self.submit_data.certificateList.length; i++) {
                var certificate = self.submit_data.certificateList[i];
                var certificateError = this.validateTrademarkCertificate(certificate);
                certificateListError.push({
                    'index': i,
                    'error': certificateError,
                });
                currentErrorMsg = certificateError.currentErrorMsg;
            }
            if(currentErrorMsg.length > 0) {
                layer.msg(currentErrorMsg[0], {icon: 5})
            }
            console.log(certificateListError)
            canSubmit = self.displayFormErrors('.trademark_certificate_form', certificateListError);
            if(!canSubmit) {
                _btnAc.removeAttr('disabled');
                self.multCaseClick = false;
                return false;
            }
        }

        var _url = isedit!=1?self.urlLink.case_build: self.urlLink.case_updata;
        var _param = JSON.stringify(self.submit_data);
        var succ = function(res){
            if(res.code == 0){
                layer.msg('立案成功',{time:1000});
                $('#case_build_dlg').modal('hide');
                _btnAc.removeAttr('disabled');
                if(self.option.pageSort==undefined){
                    //线上刷新
                    online.refreshPage();
                }else if(self.option.pageSort=='la'){
                    //立案刷新
                    $.get('/customer/queryKVList',function(data){
                        if($('#filingCustomerContent').val()!=''){
                            var val
                            var name=$('#filingCustomerContent').val()
                            for(var i=0;i<data.data.length;i++){
                                if(data.data[i].value==name){
                                    val = data.data[i].key
                                }
                            }
                        }else {
                            var val = null
                        }
                        var timeA = timeS()
                        //获取当前每页应该显示条数
                        queryS(timeA.page,timeA.num,timeA.searchKey,timeA.startDate,timeA.endDate,val)
                    })
                }else if(self.option.pageSort=='xx'){
                    //线下刷新
                    $.get('/customer/queryKVList',function(data){
                        if($('#customerContent').val()!=''){
                            var val
                            var name=$('#customerContent').val()
                            for(var i=0;i<data.data.length;i++){
                                if(data.data[i].value==name){
                                    val = data.data[i].key
                                }
                            }
                        }else {
                            var val = null
                        }
                        var timeA = timeS()
                        //获取当前每页应该显示条数
                        queryS(timeA.page,timeA.num,timeA.searchKey,timeA.startDate,timeA.endDate,val)
                    })
                }
            }
            else if (res.code==9999)
            {
                layer.msg(res.msg,{time: 1000});
                wzERP.Common.TimeoutLogin();
                _btnAc.removeAttr('disabled');
                self.multCaseClick = false;
            }
            else{
                layer.msg(res.msg,{time:1000});
                _btnAc.removeAttr('disabled');
                self.multCaseClick = false;
            }
        }
        var error = function(){
            layer.msg('网络失败，请刷新页面后重试',{time: 1000});
            _btnAc.removeAttr('disabled');
            self.multCaseClick = false;
        }
        commonFunc.ajax_get(_url,_param,succ,{type: "POST",error: error});
    },
    // 立案提交部分结束-----

    // 立案模块初始化
    init: function(url){
        var self = this;
        self.option = {
            id: '',//订单id
            orderCode: '',//订单code
            _this: '',//立案或者编辑按钮 的 JQ对象
        };//配置信息
        self.cd_od_dt = {};//订单详情信息
        self.may_case_sku_lt = [],//可立案的sku 列表
        self.may_build_case_sku_lt = {},
        self.submit_data = {}; //立案提交数据
        self.brand_lv3_obj = [];//服务选择时候 记忆所选 商标lv3项
        self.cases_detail = {}; //案件编辑时立案详情
        self._bdlv3 = {}; //商标三级检索 临时保存
        self._customerDate = {};//订单客户信息
        self.labelSort = 5000;
        self.labelSort_w = 1;
        self.urlLink = {
            cd_od_dt: url, //子订单详情接口
            case_build: '/filing/manage/add',//添加立案
            may_case_svname_check: '/filing/manage/queryServiceFormKVList', //查询服务code, 筛选服务用
            brand_sv_classify: '/filing/manage/queryServiceTypeList', //商标大类列表
            brand_svLv3_classify: '/filing/manage/searchThreeLevel',//商标三级大类列表
            case_updata: '/filing/manage/update', //更新立案
            cases_detail: '/filing/manage/filingDetail', //立案详情
            case_delete: '/filing/manage/deleteCases', //案件删除
            customer_data: '/customer/findById',//客户数据
        };
    },

    // 表单验证对象
    verifier: {
        on: 'blur',
        inline: true,
        transition: 'fade',
        fields: {
    		// 申请人
    		custId: {
    	        identifier: 'custId',
    	        rules: [
    	            {
    	                type: 'empty',
    	                prompt: '请输申请人名称'
    	            },
    	            {
    	                type: 'regExp[/^.{0,50}$/]',
    	                prompt: '申请人名称限制50字'
    	            }
    	        ]
    	    },
    	    // 营业执照
    	    businessLicence: {
    	        identifier: 'businessLicence',
    	        optional:true,
    	        rules: [{
    	            type: 'regExp[/^[a-zA-Z0-9]{15,18}$/]',
    	            prompt: '15-18位数字或字母'
    	        }]
    	    },
    	    //联系人
    	    contactName: {
    	        identifier: 'contactName',
    	        rules: [
    	            {
    	                type: 'empty',
    	                prompt: '请输入名称'
    	            },{
    	            type: 'regExp[/^.{0,20}$/]',
    	            prompt: '限20字'
    	        }]
    	    },
    	    // 名称
    	    namePre: {
    	        identifier: 'namePre',
    	        rules: [
    	            {
    	                type: 'empty',
    	                prompt: '请输名称'
    	            },
    	            {
    	                type: 'regExp[/^.{0,50}$/]',
    	                prompt: '申请人名称限制50字'
    	            }
    	        ]
    	    },
    	    nameAfter: {
    	        identifier: 'nameAfter',
    	        rules: [
    	            {
    	                type: 'empty',
    	                prompt: '请输名称'
    	            },
    	            {
    	                type: 'regExp[/^.{0,50}$/]',
    	                prompt: '申请人名称限制50字'
    	            }
    	        ]
    	    },
    	    //文件接收人
    	    fileReceiverPre: {
    	        identifier: 'fileReceiverPre',
    	        rules: [
    	            {
    	                type: 'empty',
    	                prompt: '请输名称'
    	            },
    	            {
    	                type: 'regExp[/^.{0,50}$/]',
    	                prompt: '申请人名称限制50字'
    	            }
    	        ]
    	    },
    	    //被许可人名称
    	    licensorName: {
    	        identifier: 'licensorName',
    	        rules: [
    	            {
    	                type: 'empty',
    	                prompt: '请输名称'
    	            },
    	            {
    	                type: 'regExp[/^.{0,50}$/]',
    	                prompt: '申请人名称限制50字'
    	            }
    	        ]
    	    },
    	    //变更为名称
    	    asLicensorName: {
    	        identifier: 'asLicensorName',
    	        rules: [
    	            {
    	                type: 'empty',
    	                prompt: '请输名称'
    	            },
    	            {
    	                type: 'regExp[/^.{0,50}$/]',
    	                prompt: '申请人名称限制50字'
    	            }
    	        ]
    	    },
    	    //联系电话-手机号码
    	    contactPhone: {
    	        identifier: 'contactPhone',
    	        rules: [{
    	            type: 'empty',
    	            prompt: '请输入联系电话'
    	        },
    	        {
    	            type: 'regExp[/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/]',
    	            prompt: '请输入正确的手机号码'
    	        }]
    	    },
    	    //邮编
    	    postalCode: {
    	        identifier: 'postalCode',
    	        optional:true,
    	        rules: [{
    	            type: 'regExp[/^\\d{0,10}$/]',
    	            prompt: '限10位数字'
    	        }]
    	    },
    	//地址
    	    // 申请人地址
    	    applyAddress: {
    	        identifier: 'applyAddress',
    	        rules: [
    	            {
    	                type: 'regExp[/^.{0,50}$/]',
    	                prompt: '地址限制50字'
    	            }
    	        ]
    	    },
    	    addressPre: {
    	        identifier: 'addressPre',
    	        rules: [
    	            {
    	                type: 'regExp[/^.{0,50}$/]',
    	                prompt: '地址限制50字'
    	            }
    	        ]
    	    },
    	    //商标名称
    	    trademarkName: {
    	        identifier: 'trademarkName',
    	        rules: [
    	            {
    	                type: 'empty',
    	                prompt: '请输入商标名称'
    	            },
    	            {
    	                type: 'regExp[/^.{0,20}$/]',
    	                prompt: '限制20字'
    	            }
    	        ]
    	    },
    	    //商标注册号
    	    trademarkCode: {
    	        identifier: 'trademarkCode',
    	        rules: [
    	            {
    	                type: 'empty',
    	                prompt: '请输入商标注册号'
    	            },
    	            {
    	                type: 'regExp[/^[a-zA-Z0-9]{0,20}$/]',
    	                prompt: '限20数字或字母'
    	            }
    	        ]
    	    },
    	    //许可备案号
    	    recordCode: {
    	        identifier: 'recordCode',
    	        optional:true,
    	        rules: [
    	            {
    	                type: 'empty',
    	                prompt: '请输入商标注册号'
    	            },
    	            {
    	                type: 'regExp[/^[a-zA-Z0-9]{0,20}$/]',
    	                prompt: '限20数字或字母'
    	            }
    	        ]
    	    },
    	// 图片
    	    //商标图样
    	    trademarkUrl: {
    	        identifier: 'trademarkUrl',
    	        rules: [
    	            {
    	                type: 'empty',
    	                prompt: '请上传图片'
    	            },
    	        ]
    	    },
    	    //营业执照
    	    businessLicenceUrl: {
    	        identifier: 'businessLicenceUrl',
    	        rules: [
    	            {
    	                type: 'empty',
    	                prompt: '请上传图片'
    	            },
    	        ]
    	    },
    	    //证照
    	    certificateUrl: {
    	        identifier: 'certificateUrl',
    	        rules: [
    	            {
    	                type: 'empty',
    	                prompt: '请上传图片'
    	            },
    	        ]
    	    },
    	    alterProveUrl: {
    	        identifier: 'alterProveUrl',
    	        rules: [
    	            {
    	                type: 'empty',
    	                prompt: '请上传图片'
    	            },
    	        ]
    	    },
        },
    },

    validateTrademarkRegist: function (obj) {
        var errorObj = {};
        var errorMsg = new Array();
        var currentErrorMsg = [];
        console.log(obj)
        if (this.isEmpty(obj.proposerType)) {
            errorMsg.push({
                'name': 'proposerType',
                'msg': '请选择申请人类型',
            });
            currentErrorMsg.push('请选择申请人类型');
        }
        if (this.isEmpty(obj.custName)) {
            errorMsg.push({
                'name': 'custName',
                'msg': '请输入申请人名称',
            });
            currentErrorMsg.push('请输入申请人名称');
        }
        if (this.isEmpty(obj.provinceCode) || this.isEmpty(obj.cityCode) || this.isEmpty(obj.county) || this.isEmpty(obj.applyAddress)) {
            errorMsg.push({
                'name': 'address',
                'msg': '请输入申请人详细地址',
            });
            currentErrorMsg.push('请输入申请人详细地址');
        }
        // if (this.isEmpty(obj.businessLicence)) {
        //     errorMsg.push({
        //         'name': 'businessLicence',
        //         'msg': '请输入营业执照',
        //     });
        //     currentErrorMsg.push('请输入营业执照');
        // }
        // if (this.isEmpty(obj.businessLicenceUrl)) {
        //     errorMsg.push({
        //         'name': 'businessLicenceUrl',
        //         'msg': '请上传营业执照',
        //     });
        //     currentErrorMsg.push('请上传营业执照');
        // }
        // if (this.isEmpty(obj.contactName)) {
        //     errorMsg.push({
        //         'name': 'contactName',
        //         'msg': '请输入联系人姓名',
        //     });
        //     currentErrorMsg.push('请输入联系人姓名');
        // }
        // if (this.isEmpty(obj.contactPhone)) {
        //     errorMsg.push({
        //         'name': 'contactPhone',
        //         'msg': '请输入联系人电话',
        //     });
        //     currentErrorMsg.push('请输入联系人电话');
        // }
        // if (!this.isPhoneNumber(obj.contactPhone)) {
        //     errorMsg.push({
        //         'name': 'contactPhoneFormat',
        //         'msg': '请输入正确的电话号码',
        //     });
        //     currentErrorMsg.push('请输入正确的电话号码');
        // }
        // if(this.isEmpty(obj.trademarkName)) {
        //     errorMsg.push({
        //         'name': 'trademarkName',
        //         'msg':  '商标名称不能为空',
        //     });
        //     currentErrorMsg = '商标名称不能为空';
        // }
        if (this.isEmpty(obj.trademarkType)) {
            errorMsg.push({
                'name': 'trademarkType',
                'msg': '请选择商标类型',
            });
            currentErrorMsg.push('请选择商标类型');
        }
        if (this.isEmpty(obj.trademarkKind)) {
            errorMsg.push({
                'name': 'trademarkKind',
                'msg': '请选择商标种类',
            });
            currentErrorMsg.push('请选择商标种类');
        }
        // if (this.isEmpty(obj.trademarkUrl)) {
        //     errorMsg.push({
        //         'name': 'trademarkUrl',
        //         'msg': '请上传商标图样',
        //     });
        //     currentErrorMsg.push('请上传商标图样');
        // }
        if (this.isEmpty(obj.specifiedColor)) {
            errorMsg.push({
                'name': 'specifiedColor',
                'msg': '请选择是否指定颜色',
            });
            currentErrorMsg.push('请选择是否指定颜色');
        }
        errorObj.errorMsg = errorMsg;
        errorObj.currentErrorMsg = currentErrorMsg;
        return errorObj;
    },
    validateTrademarkLicence: function (obj) {
        var errorObj = {};
        var errorMsg = new Array();
        var currentErrorMsg = [];
        console.log(obj)
        if (this.isEmpty(obj.trademarkCode)) {
            errorMsg.push({
                'name': 'trademarkCode',
                'msg': '请输入商标注册号',
            });
            currentErrorMsg.push('请输入商标注册号');
        }
        if (this.isEmpty(obj.trademarkName)) {
            errorMsg.push({
                'name': 'trademarkName',
                'msg': '请输入商标名称',
            });
            currentErrorMsg.push('请输入商标名称');
        }
        if (this.isEmpty(obj.internationClassCode)) {
            errorMsg.push({
                'name': 'internationClassCode',
                'msg': '请输入国际分类',
            });
            currentErrorMsg.push('请输入国际分类');
        }
        // if(this.isEmpty(obj.trademarkKind)) {
        //     errorMsg.push({
        //         'name': 'trademarkKind',
        //         'msg':  '请选择商标种类',
        //     });
        //     currentErrorMsg.push('请选择商标种类';
        // }
        // if(this.isEmpty(obj.shareTrademark)) {
        //     errorMsg.push({
        //         'name': 'shareTrademark',
        //         'msg':  '请选择是否共有商标',
        //     });
        //     currentErrorMsg.push('请选择是否共有商标';
        // }
        //
        // if(this.isEmpty(obj.nationality)) {
        //     errorMsg.push({
        //         'name': 'nationality',
        //         'msg':  '请选择注册人国籍',
        //     });
        //     currentErrorMsg.push('请选择注册人国籍';
        // }
        //
        // if(this.isEmpty(obj.proposerType)) {
        //     errorMsg.push({
        //         'name': 'proposerType',
        //         'msg':  '请选择注册人类型',
        //     });
        //     currentErrorMsg.push('请选择注册人类型';
        // }
        // if(this.isEmpty(obj.licenceNationality)) {
        //     errorMsg.push({
        //         'name': 'licenceNationality',
        //         'msg':  '请选择被许可人国籍',
        //     });
        //     currentErrorMsg.push('请选择被许可人国籍';
        // }
        // if(this.isEmpty(obj.licenceProposerType)) {
        //     errorMsg.push({
        //         'name': 'licenceProposerType',
        //         'msg':  '请选择被许可人类型',
        //     });
        //     currentErrorMsg.push('请选择被许可人类型';
        // }
        if (this.isEmpty(obj.name)) {
            errorMsg.push({
                'name': 'name',
                'msg': '请输入被许可人名称',
            });
            currentErrorMsg.push('请输入被许可人名称');
        }
        if (this.isEmpty(obj.provinceCode) || this.isEmpty(obj.cityCode) || this.isEmpty(obj.county) || this.isEmpty(obj.address)) {
            errorMsg.push({
                'name': 'address',
                'msg': '请输入被许可人详细地址',
            });
            currentErrorMsg.push('请输入被许可人详细地址');
        }
        // if(this.isEmpty(obj.certificateUrl)) {
        //     errorMsg.push({
        //         'name': 'certificateUrl',
        //         'msg':  '请上传被许可人证照',
        //     });
        //     currentErrorMsg.push('请上传被许可人证照');
        // }
        if (this.isEmpty(obj.contactName)) {
            errorMsg.push({
                'name': 'contactName',
                'msg': '请输入联系人姓名',
            });
            currentErrorMsg.push('请输入联系人姓名');
        }
        if (this.isEmpty(obj.contactPhone)) {
            errorMsg.push({
                'name': 'contactPhone',
                'msg': '请输入联系人电话',
            });
            currentErrorMsg.push('请输入联系人电话');
        }
        if (!this.isPhoneNumber(obj.contactPhone)) {
            errorMsg.push({
                'name': 'contactPhoneFormat',
                'msg': '请输入正确的电话号码',
            });
            currentErrorMsg.push('请输入正确的电话号码');
        }
        if (this.isEmpty(obj.postalCode)) {
            errorMsg.push({
                'name': 'postalCode',
                'msg': '请输入邮政编码',
            });
            currentErrorMsg.push('请输入邮政编码');
        }
        // if(this.isEmpty(obj.trademarkUrl)) {
        //     errorMsg.push({
        //         'name': 'trademarkUrl',
        //         'msg':  '请上传商标注册证',
        //     });
        //     currentErrorMsg.push('请上传商标注册证');
        // }
        errorObj.errorMsg = errorMsg;
        errorObj.currentErrorMsg = currentErrorMsg;
        return errorObj;
    },
    validateTrademarkCertificate: function (obj) {
        var errorObj = {};
        var errorMsg = new Array();
        var currentErrorMsg = [];
        console.log(obj)
        if (this.isEmpty(obj.trademarkCode)) {
            errorMsg.push({
                'name': 'trademarkCode',
                'msg': '请输入商标注册号',
            });
            currentErrorMsg.push('请输入商标注册号');
        }
        if (this.isEmpty(obj.trademarkName)) {
            errorMsg.push({
                'name': 'trademarkName',
                'msg': '请输入商标名称',
            });
            currentErrorMsg.push('请输入商标名称');
        }
        if (this.isEmpty(obj.internationClassCode)) {
            errorMsg.push({
                'name': 'internationClassCode',
                'msg': '请输入国际分类',
            });
            currentErrorMsg.push('请输入国际分类');
        }
        // if(this.isEmpty(obj.trademarkKind)) {
        //     errorMsg.push({
        //         'name': 'trademarkKind',
        //         'msg':  '请选择商标种类',
        //     });
        //     currentErrorMsg.push('请选择商标种类');
        // }
        // if(this.isEmpty(obj.shareTrademark)) {
        //     errorMsg.push({
        //         'name': 'shareTrademark',
        //         'msg':  '请选择是否共有商标',
        //     });
        //     currentErrorMsg.push('请选择是否共有商标');
        // }
        //
        // if(this.isEmpty(obj.nationality)) {
        //     errorMsg.push({
        //         'name': 'nationality',
        //         'msg':  '请选择注册人国籍',
        //     });
        //     currentErrorMsg.push('请选择注册人国籍');
        // }
        //
        // if(this.isEmpty(obj.proposerType)) {
        //     errorMsg.push({
        //         'name': 'proposerType',
        //         'msg':  '请选择注册人类型',
        //     });
        //     currentErrorMsg.push('请选择注册人类型');
        // }
        // if(this.isEmpty(obj.causeDescript)) {
        //     errorMsg.push({
        //         'name': 'causeDescript',
        //         'msg':  '请输入补证原因',
        //     });
        //     currentErrorMsg.push('请输入补证原因');
        // }
        if (this.isEmpty(obj.contactName)) {
            errorMsg.push({
                'name': 'contactName',
                'msg': '请输入联系人姓名',
            });
            currentErrorMsg.push('请输入联系人姓名');
        }
        if (this.isEmpty(obj.contactPhone)) {
            errorMsg.push({
                'name': 'contactPhone',
                'msg': '请输入联系人电话',
            });
            currentErrorMsg.push('请输入联系人电话');
        }
        if (!this.isPhoneNumber(obj.contactPhone)) {
            errorMsg.push({
                'name': 'contactPhoneFormat',
                'msg': '请输入正确的电话号码',
            });
            currentErrorMsg.push('请输入正确的电话号码');
        }
        if (this.isEmpty(obj.postalCode)) {
            errorMsg.push({
                'name': 'postalCode',
                'msg': '请输入邮政编码',
            });
            currentErrorMsg.push('请输入邮政编码');
        }
        // if (this.isEmpty(obj.trademarkUrl)) {
        //     errorMsg.push({
        //         'name': 'trademarkUrl',
        //         'msg': '请上传商标注册证',
        //     });
        //     currentErrorMsg.push('请上传商标注册证');
        // }
        errorObj.errorMsg = errorMsg;
        errorObj.currentErrorMsg = currentErrorMsg;
        return errorObj;
    },
    validateTrademarkExtend: function (obj) {
        var errorObj = {};
        var errorMsg = new Array();
        var currentErrorMsg = [];
        console.log(obj)
        if (this.isEmpty(obj.trademarkCode)) {
            errorMsg.push({
                'name': 'trademarkCode',
                'msg': '请输入商标注册号',
            });
            currentErrorMsg.push('请输入商标注册号');
        }

        if (this.isEmpty(obj.trademarkName)) {
            errorMsg.push({
                'name': 'trademarkName',
                'msg': '请输入商标名称',
            });
            currentErrorMsg.push('请输入商标名称');
        }
        if (this.isEmpty(obj.internationClassCode)) {
            errorMsg.push({
                'name': 'internationClassCode',
                'msg': '请输入国际分类',
            });
            currentErrorMsg.push('请输入国际分类');
        }
        // if(this.isEmpty(obj.trademarkKind)) {
        //     errorMsg.push({
        //         'name': 'trademarkKind',
        //         'msg':  '请选择商标种类',
        //     });
        //     currentErrorMsg.push('请选择商标种类');
        // }
        // if(this.isEmpty(obj.bussnessType)) {
        //     errorMsg.push({
        //         'name': 'bussnessType',
        //         'msg':  '请选择业务类型',
        //     });
        //     currentErrorMsg.push('请选择业务类型');
        // }
        // if(this.isEmpty(obj.shareTrademark)) {
        //     errorMsg.push({
        //         'name': 'shareTrademark',
        //         'msg':  '请选择是否共有商标',
        //     });
        //     currentErrorMsg.push('请选择是否共有商标');
        // }
        //
        // if(this.isEmpty(obj.nationality)) {
        //     errorMsg.push({
        //         'name': 'nationality',
        //         'msg':  '请选择注册人国籍',
        //     });
        //     currentErrorMsg.push('请选择注册人国籍');
        // }
        //
        // if(this.isEmpty(obj.proposerType)) {
        //     errorMsg.push({
        //         'name': 'proposerType',
        //         'msg':  '请选择注册人类型',
        //     });
        //     currentErrorMsg.push('请选择注册人类型');
        // }
        if (this.isEmpty(obj.contactName)) {
            errorMsg.push({
                'name': 'contactName',
                'msg': '请输入联系人姓名',
            });
            currentErrorMsg.push('请输入联系人姓名');
        }
        if (this.isEmpty(obj.contactPhone)) {
            errorMsg.push({
                'name': 'contactPhone',
                'msg': '请输入联系人电话',
            });
            currentErrorMsg.push('请输入联系人电话');
        }
        if (!this.isPhoneNumber(obj.contactPhone)) {
            errorMsg.push({
                'name': 'contactPhoneFormat',
                'msg': '请输入正确的电话号码',
            });
            currentErrorMsg.push('请输入正确的电话号码');
        }
        if (this.isEmpty(obj.postalCode)) {
            errorMsg.push({
                'name': 'postalCode',
                'msg': '请输入邮政编码',
            });
            currentErrorMsg.push('请输入邮政编码');
        }
        // if(this.isEmpty(obj.trademarkUrl)) {
        //     errorMsg.push({
        //         'name': 'trademarkUrl',
        //         'msg':  '请上传商标注册证',
        //     });
        //     currentErrorMsg.push('请上传商标注册证');
        // }
        errorObj.errorMsg = errorMsg;
        errorObj.currentErrorMsg = currentErrorMsg;
        return errorObj;
    },
    validateTrademarkTransfer: function (obj) {
        var errorObj = {};
        var errorMsg = new Array();
        var currentErrorMsg = [];
        console.log(obj)
        if (this.isEmpty(obj.trademarkCode)) {
            errorMsg.push({
                'name': 'trademarkCode',
                'msg': '请输入商标注册号',
            });
            currentErrorMsg.push('请输入商标注册号');
        }
        if (this.isEmpty(obj.trademarkName)) {
            errorMsg.push({
                'name': 'trademarkName',
                'msg': '请输入商标名称',
            });
            currentErrorMsg.push('请输入商标名称');
        }
        if (this.isEmpty(obj.internationClassCode)) {
            errorMsg.push({
                'name': 'internationClassCode',
                'msg': '请输入国际分类',
            });
            currentErrorMsg.push('请输入国际分类');
        }
        if (this.isEmpty(obj.contactList)) {
            errorMsg.push({
                'name': 'contactList',
                'msg': '请至少选择一个受让人',
            });
            currentErrorMsg.push('请至少选择一个受让人');
        }

        if (this.isEmpty(obj.contactName)) {
            errorMsg.push({
                'name': 'contactName',
                'msg': '请输入联系人姓名',
            });
            currentErrorMsg.push('请输入联系人姓名');
        }
        if (this.isEmpty(obj.contactPhone)) {
            errorMsg.push({
                'name': 'contactPhone',
                'msg': '请输入联系人电话',
            });
            currentErrorMsg.push('请输入联系人电话');
        }
        if (!this.isPhoneNumber(obj.contactPhone)) {
            errorMsg.push({
                'name': 'contactPhoneFormat',
                'msg': '请输入正确的电话号码',
            });
            currentErrorMsg.push('请输入正确的电话号码');
        }
        if (this.isEmpty(obj.postalCode)) {
            errorMsg.push({
                'name': 'postalCode',
                'msg': '请输入邮政编码',
            });
            currentErrorMsg.push('请输入邮政编码');
        }

        if (!this.isEmpty(obj.contactList) && obj.contactList.length > 0) {
            var contactListError = [];
            for (var i = 0; i < obj.contactList.length; i++) {
                var contact = obj.contactList[i];
                var contactError = {};
                contactError.error = [];
                // if (this.isEmpty(contact.nationality)) {
                //     contactError.error.push({
                //         'name': 'nationality',
                //         'msg':  '请选择注册人国籍',
                //     });
                //     currentErrorMsg.push('请选择注册人国籍');
                // }
                // if(this.isEmpty(contact.proposerType)) {
                //     contactError.error.push({
                //         'name': 'proposerType',
                //         'msg':  '请选择注册人类型',
                //     });
                //     currentErrorMsg.push('请选择注册人类型');
                // }
                if (this.isEmpty(contact.contactName)) {
                    contactError.error.push({
                        'name': 'contactName',
                        'msg': '请输入受让人名称',
                    });
                    currentErrorMsg.push('请输入受让人名称');
                }
                if (this.isEmpty(contact.address)) {
                    contactError.error.push({
                        'name': 'address',
                        'msg': '请选择受让人详细地址',
                    });
                    currentErrorMsg.push('请选择受让人详细地址');
                }
                contactListError.push(contactError);
            }
            errorMsg.push({
                'name': 'contactList',
                'contactListError': contactListError,
                'msg': '',
            });
        }

        errorObj.errorMsg = errorMsg;
        errorObj.currentErrorMsg = currentErrorMsg;
        return errorObj;
    },
    validateTrademarkChange: function (obj) {
        var errorObj = {};
        var errorMsg = new Array();
        var currentErrorMsg = [];
        console.log(obj)
        if (this.isEmpty(obj.trademarkCode)) {
            errorMsg.push({
                'name': 'trademarkCode',
                'msg': '请输入商标注册号',
            });
            currentErrorMsg.push('请输入商标注册号');
        }
        if (this.isEmpty(obj.trademarkName)) {
            errorMsg.push({
                'name': 'trademarkName',
                'msg': '请输入商标名称',
            });
            currentErrorMsg.push('请输入商标名称');
        }
        if (this.isEmpty(obj.internationClassCode)) {
            errorMsg.push({
                'name': 'internationClassCode',
                'msg': '请输入国际分类',
            });
            currentErrorMsg.push('请输入国际分类');
        }

        if (obj.changeType == 0) {
            // 变更注册人
            if (!this.isEmpty(obj.registerList) && obj.registerList.length > 0) {
                var registertListError = [];
                for (var i = 0; i < obj.registerList.length; i++) {
                    var register = obj.registerList[i];
                    var registerError = {};
                    registerError.error = [];
                    if (this.isEmpty(register.namePre)) {
                        registerError.error.push({
                            'name': 'namePre',
                            'msg': '请输入变更前名称',
                        });
                        currentErrorMsg.push('请输入变更前名称');
                    }
                    if (this.isEmpty(register.nameAfter)) {
                        registerError.error.push({
                            'name': 'nameAfter',
                            'msg': '请输入变更后名称',
                        });
                        currentErrorMsg.push('请输入变更后名称');
                    }

                    if (this.isEmpty(register.provinceCodePre) || this.isEmpty(register.cityCodePre) || this.isEmpty(register.countyPre) || this.isEmpty(register.addressPre)) {
                        registerError.error.push({
                            'name': 'addressPre',
                            'msg': '请输入变更前地址',
                        });
                        currentErrorMsg.push('请输入变更前地址');
                    }
                    if (this.isEmpty(register.provinceCodeAfter) || this.isEmpty(register.cityCodeAfter) || this.isEmpty(register.countyAfter) || this.isEmpty(register.addressAfter)) {
                        registerError.error.push({
                            'name': 'addressAfter',
                            'msg': '请输入变更后地址',
                        });
                        currentErrorMsg.push('请输入变更后地址');
                    }
                    registertListError.push(registerError);
                }
                errorMsg.push({
                    'name': 'registertList',
                    'registertListError': registertListError,
                    'msg': '',
                });
            }
        } else if (obj.changeType == 1) {
            // 变更代理
            if (!this.isEmpty(obj.proxyer)) {
                var proxyer = obj.proxyer;
                var proxyerError = [];
                if (this.isEmpty(proxyer.namePre)) {
                    proxyerError.push({
                        'name': 'namePre',
                        'msg': '请输入变更前代理人名称',
                    });
                    currentErrorMsg.push('请输入变更前代理人名称');
                }
                if (this.isEmpty(proxyer.provinceCodePre) || this.isEmpty(proxyer.cityCodePre) || this.isEmpty(proxyer.countyPre) || this.isEmpty(proxyer.addressPre)) {
                    proxyerError.push({
                        'name': 'addressPre',
                        'msg': '请输入变更前地址',
                    });
                    currentErrorMsg.push('请输入变更前地址');
                }
                if (this.isEmpty(proxyer.fileReceiverPre)) {
                    proxyerError.push({
                        'name': 'fileReceiverPre',
                        'msg': '请输入变更前文件接收人',
                    });
                    currentErrorMsg.push('请输入变更前文件接收人');
                }
                if (this.isEmpty(proxyer.postalCodePre)) {
                    proxyerError.push({
                        'name': 'postalCodePre',
                        'msg': '请输入变更前邮编',
                    });
                    currentErrorMsg.push('请输入变更前邮编');
                }
                if (this.isEmpty(proxyer.nameAfter)) {
                    proxyerError.push({
                        'name': 'nameAfter',
                        'msg': '请输入变更后代理人名称',
                    });
                    currentErrorMsg.push('请输入变更后代理人名称');
                }
                if (this.isEmpty(proxyer.provinceCodeAfter) || this.isEmpty(proxyer.cityCodeAfter) || this.isEmpty(proxyer.countyAfter) || this.isEmpty(proxyer.addressAfter)) {
                    proxyerError.push({
                        'name': 'addressAfter',
                        'msg': '请输入变更后地址',
                    });
                    currentErrorMsg.push('请输入变更后地址');
                }
                if (this.isEmpty(proxyer.fileReceiverAfter)) {
                    proxyerError.push({
                        'name': 'fileReceiverAfter',
                        'msg': '请输入变更后文件接收人',
                    });
                    currentErrorMsg.push('请输入变更后文件接收人');
                }
                if (this.isEmpty(proxyer.postalCodeAfter)) {
                    proxyerError.push({
                        'name': 'postalCodeAfter',
                        'msg': '请输入变更后邮编',
                    });
                    currentErrorMsg.push('请输入变更后邮编');
                }
                errorMsg.push({
                    'name': 'proxyer',
                    'msg': '请完善代理人信息',
                    'changeProxyerError': proxyerError,
                });
            }

        } else if (obj.changeType == 2) {
            // 变更许可
            if (!this.isEmpty(obj.licencer)) {
                var licencer = obj.licencer;
                var licencerError = [];
                if (this.isEmpty(licencer.recordCode)) {
                    licencerError.push({
                        'name': 'recordCode',
                        'msg': '请输入许可备案号',
                    });
                    currentErrorMsg.push('请输入许可备案号');
                }
                if (this.isEmpty(licencer.licensorName)) {
                    licencerError.push({
                        'name': 'licensorName',
                        'msg': '请输入许可人名称',
                    });
                    currentErrorMsg.push('请输入许可人名称');
                }
                if (this.isEmpty(licencer.asLicensorName)) {
                    licencerError.push({
                        'name': 'asLicensorName',
                        'msg': '请输入变更人名称',
                    });
                    currentErrorMsg.push('请输入变更人名称');
                }
                // if (this.isEmpty(licencer.certificateUrl)) {
                //     licencerError.push({
                //         'name': 'certificateUrl',
                //         'msg': '请上传证件照',
                //     });
                //     currentErrorMsg.push('请上传证件照');
                // }
                // if (this.isEmpty(licencer.alterProveUrl)) {
                //     licencerError.push({
                //         'name': 'alterProveUrl',
                //         'msg': '请上传工商变更证明',
                //     });
                //     currentErrorMsg.push('请上传工商变更证明');
                // }
            }
            errorMsg.push({
                'name': 'licencer',
                'msg': '请完善许可人信息',
                'changeLicencerError': licencerError,
            });
        }
        if (this.isEmpty(obj.contactName)) {
            errorMsg.push({
                'name': 'contactName',
                'msg': '请输入联系人姓名',
            });
            currentErrorMsg.push('请输入联系人姓名');
        }
        if (this.isEmpty(obj.contactPhone)) {
            errorMsg.push({
                'name': 'contactPhone',
                'msg': '请输入联系人电话',
            });
            currentErrorMsg.push('请输入联系人电话');
        }
        if (!this.isPhoneNumber(obj.contactPhone)) {
            errorMsg.push({
                'name': 'contactPhoneFormat',
                'msg': '请输入正确的电话号码',
            });
            currentErrorMsg.push('请输入正确的电话号码');
        }
        if (this.isEmpty(obj.postalCode)) {
            errorMsg.push({
                'name': 'postalCode',
                'msg': '请输入邮政编码',
            });
            currentErrorMsg.push('请输入邮政编码');
        }
        errorObj.errorMsg = errorMsg;
        errorObj.currentErrorMsg = currentErrorMsg;
        return errorObj;
    },
    // 显示表单错误
    displayFormErrors: function (formSelector, errorList) {
        $('.form_error').remove();
        $('*').removeClass('error');
        var canSubmit = true;
        console.log(errorList)
        for (var i = 0; i < errorList.length; i++) {
            var formError = errorList[i];
            if (formError.error && formError.error.errorMsg.length > 0) {
                for (var j = 0; j < formError.error.errorMsg.length; j++) {
                    var selector;
                    var displayType = 'red-border';
                    if (formError.error.errorMsg[j].name.endsWith('Format')) {
                        selector = '[name=' + formError.error.errorMsg[j].name.substr(0, formError.error.errorMsg[j].name.length - 6) + ']';
                        displayType = 'tips';
                        canSubmit = false;
                    } else if (formError.error.errorMsg[j].name.endsWith('List')) {
                        if (formError.error.errorMsg[j].hasOwnProperty('contactListError')) {
                            var contactListError = formError.error.errorMsg[j].contactListError;
                            for (var k = 0; k < contactListError.length; k++) {
                                var subSelector = '';
                                var subDisplayType = '';
                                for (var x = 0; x < contactListError[k].error.length; x++) {
                                    subSelector = '[name=' + contactListError[k].error[x].name + ']';
                                    if (contactListError[k].error.length > 0) {
                                        canSubmit = false;
                                    }
                                    if (contactListError[k].error[x].name == 'address') {
                                        subDisplayType = 'address';
                                        subSelector = '[name=address]';
                                    } else if (contactListError[k].error[x].name.endsWith('Url')) {
                                        subDisplayType = 'url';
                                        subSelector = '[name=' + contactListError[k].error[x].name + ']';
                                    } else {
                                        subSelector = '[name=' + contactListError[k].error[x].name + ']';
                                    }
                                    if ($('.trademark_transfer_form_child').eq(k).find(subSelector).attr('type') == 'radio') {
                                        subDisplayType = 'radio';
                                    }
                                    var subInput = $(formSelector).eq(i).siblings('.trademark_transfer_form_child').eq(k).find(subSelector);
                                    subInput.parents('.field').addClass('error');
                                    subInput.focus(function(){
                                        $(this).parents('.field').removeClass('error');
                                    });
                                }
                            }
                        }

                        if (formError.error.errorMsg[j].hasOwnProperty('registertListError')) {
                            var registertListError = formError.error.errorMsg[j].registertListError;
                            for (var k = 0; k < registertListError.length; k++) {
                                var subSelector = '';
                                var subDisplayType = '';
                                for (var x = 0; x < registertListError[k].error.length; x++) {
                                    if (registertListError[k].error.length > 0) {
                                        canSubmit = false;
                                    }
                                    subSelector = '[name=' + registertListError[k].error[x].name + ']';
                                    if (registertListError[k].error[x].name == 'address') {
                                        subDisplayType = 'address';
                                        subSelector = '[name=address]';
                                    } else if (registertListError[k].error[x].name.endsWith('Url')) {
                                        subDisplayType = 'url';
                                        subSelector = '[name=' + registertListError[k].error[x].name + ']';
                                    } else {
                                        subSelector = '[name=' + registertListError[k].error[x].name + ']';
                                    }
                                    if ($('.trademark_change_form_child').eq(k).find(subSelector).attr('type') == 'radio') {
                                        subDisplayType = 'radio';
                                    }
                                    var subInput = $(formSelector).eq(i).siblings('.trademark_change_form_child').eq(k).find(subSelector);
                                    subInput.parents('.field').addClass('error');
                                    subInput.focus(function(){
                                        $(this).parents('.field').removeClass('error');
                                    });
                                }
                            }
                        }

                    } else if (formError.error.errorMsg[j].hasOwnProperty('changeProxyerError')) {
                        var proxyerError = formError.error.errorMsg[j].changeProxyerError;
                        if (proxyerError.length > 0) {
                            canSubmit = false;
                        }
                        for (var y = 0; y < proxyerError.length; y++) {
                            var subSelector = '';
                            var subDisplayType = '';
                            subSelector = '[name=' + proxyerError[y].name + ']';
                            var subInput = $(formSelector).siblings('.trademark_change_form_child').find(subSelector);
                            subInput.parents('.field').addClass('error');
                            subInput.focus(function(){
                                $(this).parents('.field').removeClass('error');
                            });
                        }
                    } else if (formError.error.errorMsg[j].hasOwnProperty('changeLicencerError')) {
                        var licencerError = formError.error.errorMsg[j].changeLicencerError;
                        if (licencerError.length > 0) {
                            canSubmit = false;
                        }
                        for (var z = 0; z < licencerError.length; z++) {
                            var subSelector = '';
                            var subDisplayType = '';
                            if (licencerError[z].name.endsWith('Url')) {
                                subDisplayType = 'url';
                            }
                            subSelector = '[name=' + licencerError[z].name + ']';
                            var subInput =  $(formSelector).siblings('.trademark_change_form_child').find(subSelector);
                            subInput.parents('.field').addClass('error');
                            subInput.focus(function(){
                                $(this).parents('.field').removeClass('error');
                            });
                        }
                    } else if (formError.error.errorMsg[j].hasOwnProperty('proxyerError')) {
                        var proxyerError = formError.error.errorMsg[j].proxyerError;
                        if (proxyerError.length > 0) {
                            canSubmit = false;
                        }
                        for (var m = 0; m < proxyerError.length; m++) {
                            var subSelector = '';
                            var subDisplayType = '';
                            subSelector = '[name=' + proxyerError[m].name + ']';
                            var subInput = $(formSelector).find(subSelector);
                            subInput.parents('.field').addClass('error');
                            subInput.focus(function(){
                                $(this).parents('.field').removeClass('error');
                            });
                        }
                    } else if (formError.error.errorMsg[j].hasOwnProperty('licencerError')) {
                        var licencerError = formError.error.errorMsg[j].licencerError;
                        if (licencerError.length > 0) {
                            canSubmit = false;
                        }
                        for (var n = 0; n < licencerError.length; n++) {
                            var subSelector = '';
                            var subDisplayType = '';
                            if (licencerError[n].name.endsWith('Url')) {
                                subDisplayType = 'url';
                            }
                            subSelector = '[name=' + licencerError[n].name + ']';
                            var subInput = $(formSelector).find(subSelector);
                            subInput.parents('.field').addClass('error');
                            subInput.focus(function(){
                                $(this).parents('.field').removeClass('error');
                            });
                        }
                    }  else if (formError.error.errorMsg[j].name == 'internationClassCode') {
                        displayType = 'internationClassCode';
                        selector = 'input[name=internationClassCode]';
                        canSubmit = false;
                    } else if (formError.error.errorMsg[j].name.endsWith('Url')) {
                        displayType = 'url';
                        selector = '[name=' + formError.error.errorMsg[j].name + ']';
                        canSubmit = false;
                    } else {
                        selector = '[name=' + formError.error.errorMsg[j].name + ']';
                        canSubmit = false;
                    }
                    var input = $(formSelector).eq(errorList[i].index).find(selector);
                    input.parents('.field').addClass('error');
                    input.focus(function(){
                        $(this).parents('.field').removeClass('error');
                    });
                }
            }
        }
        return canSubmit;
    },
    isEmpty: function(any) {
        if(any && any != '') {
            return false;
        } else {
            return true;
        }
    },
    isPhoneNumber: function (phone) {
        var myreg = /^1[34578]\d{9}$/;
        return myreg.test(phone);
    }
}
template.defaults.imports.numtocn = function(val){
    return NumToCN.run(val-0);
}
template.defaults.imports.timesdhms = function(val){
    if(val!=null){
        var _time = new Date(val-0);
        return _time.getFullYear()+'-'+(_time.getMonth()+1)+'-'+_time.getDate()+' '+_time.getHours()+':'+_time.getMinutes()+':'+_time.getSeconds();
    }else{
        return '';
    }
}
template.defaults.imports.timestamp = function(val){
    if(val!=null){
        var _time = new Date(val-0);
        return _time.getFullYear()+'-'+(_time.getMonth()+1)+'-'+_time.getDate();
    }else{
        return '';
    }
} 
template.defaults.imports.jsontostr = function(val){
    if(val!=null){
        return JSON.parse(val);
    }else{ return ''}
}
// 数字转换插件 NumToCN.run(num) 调用
var NumToCN = {
	chnNumChar: ["零","一","二","三","四","五","六","七","八","九"],
	chnUnitSection: ["","万","亿","万亿","亿亿"],
	chnUnitChar: ["","十","百","千"],
	sectionToCN: function(section){
		var self = this;
		var strIns = '', chnStr = '';
		var unitPos = 0;
		var zero = true;
		while(section > 0){
		    var v = section % 10;
		    if(v === 0){
		        if(!zero){
		            zero = true;
		            chnStr = self.chnNumChar[v] + chnStr;
		          } 
		    }else{
		          zero = false;
		          strIns = self.chnNumChar[v];
		          strIns += self.chnUnitChar[unitPos];
		          chnStr = strIns + chnStr;
		    }
		    unitPos++;
		    section = Math.floor(section / 10);
		}
		return chnStr;
	},
	run: function(num){
		var self = this;
		var unitPos = 0;
	    var strIns = '', chnStr = '';
	    var needZero = false;
	    if(num === 0){
	        return self.chnNumChar[0];
	    }
	    while(num > 0){
	        var section = num % 10000;
	        if(needZero){
	            chnStr = self.chnNumChar[0] + chnStr;
	        }
	        strIns = self.sectionToCN(section);
	        strIns += (section !== 0) ? self.chnUnitSection[unitPos] : self.chnUnitSection[0];
	        chnStr = strIns + chnStr;
	        needZero = (section < 1000) && (section > 0);
	        num = Math.floor(num / 10000);
	        unitPos++;
	    }
	    return chnStr;
	},
}